ignore errors in .hql in oozie workflow - hive

I implemented the below statements in .hql file and call this file from workflow.xml in Oozie. I do not want the Oozie workflow to fail in case that table1 does not exist i.e to ignore error if alter statement fails. I used SET hive.cli.errors.ignore=true;
but this did not help. Any suggestions?
SET hive.cli.errors.ignore=true;
alter table table1 SET TBLPROPERTIES('EXTERNAL'='FALSE');

Related

How to do multiple commands one execute in the HSQLDB GUI?

I have a number of command that I want to do from the GUI. I want to do many groups of these, but I can't get a single group to work. I presume I need to somehow force commits between them, but I can't figure out how to do that. If I execute each one of these commands by itself in order, everything works as expected.
I'm using the EPSG.dat from GeoTools' EPSG.zip.
unzip EPSG.zip
perl -pi -e 's/readonly=true/readonly=false/' EPSG.properties
java -jar hsqldb-2.4.1.jar
jdbc:hsqldb:file:./EPSG
SET AUTOCOMMIT true; -- Press Execute SQL, but this doesn't seem to help.
CREATE TEXT TABLE EPSG_UNITOFMEASURE_COPY (LIKE EPSG_UNITOFMEASURE);
GRANT all ON EPSG_UNITOFMEASURE_COPY TO public;
SET TABLE EPSG_UNITOFMEASURE_COPY SOURCE 'EPSG_UNITOFMEASURE_COPY.csv;encoding=UTF-8';
INSERT INTO EPSG_UNITOFMEASURE_COPY SELECT * FROM EPSG_UNITOFMEASURE;
SET TABLE EPSG_UNITOFMEASURE_COPY SOURCE OFF;
I then get an error of:
user lacks privilege or object not found: EPSG_UNITOFMEASURE_COPY / Error Code: -5501 / State: 42501
I am pretty sure this is an object not found case.
You cannot execute these commands as one block. When a schema definition statement refers to a schema object, that object must already exist.
Execute the CREATE TEXT TABLE, then you can execute the rest as a block.

Hive query error encountered near token TOK_TMP_FILE

I get a long error. Below is the first few lines
TExecuteStatementResp(status=TStatus(statusCode=3, infoMessages=["*org.apache.hive.service.cli.HiveSQLException:Error while compiling statement: FAILED: SemanticException 0:0 Error creating temporary folder on: maprfs:/user/hive/warehouse/wh_db.db. Error encountered near token 'TOK_TMP_FILE':28:27", 'org.apache.hive.service.cli.operation.Operation:toSQLException:Operation.java:388', 'org.apache.hive.service.cli.operation.SQLOperation:prepare:SQLOperation.java:193', 'org.apache.hive.service.cli.operation.SQLOperation:runInternal:SQLOperation.java:276',`
According to this thread the error while creating table based on a select query is because the user does not have write permission to the db where the user is connected.
HIVE CREATE TABLE sematicException 0:0
I'm running my query from a db where the user has write access. So in below query, user has write permission to db2 and read permissions to db1 and db3
Query
use db2;
CREATE TABLE tbl123 AS
SELECT FROM db1.tbl1 t1
INNER JOIN tbl2 t2 ON t1.key = t2.key
INNER JOIN db3.tbl3 t3 ON t1.key2 = t3.key;
Also when the query is executed by logging into a shell console, it runs fine. But when run from a program using python-pyhive, this error occurs. I am using below config to run queries. With default and tez engine, the query executed successfully from shell. Only using pyhive I get this error
set hive.execution.engine=tez
set hive.vectorized.execution.enabled = true
set hive.vectorized.execution.reduce.enabled = true
please check user has permission to create temporary folder in the location.

Creating table in Firebird script causes "unsuccessful metadata update" with deadlock

I have the following script that I run using "isql -i scriptfile.sql":
CONNECT C:\Databasefile.fdb USER user PASSWORD password;
SET TERM !! ;
EXECUTE BLOCK AS BEGIN
IF (EXISTS(SELECT 1 FROM rdb$relations WHERE rdb$relation_name = 'MYTABLE')) THEN
EXECUTE STATEMENT 'DROP TABLE MYTABLE;';
END!!
SET TERM ; !!
CREATE TABLE MYTABLE
(
MYCOLUMN VARCHAR(14) NOT NULL
);
The very first time I run this (when the table does not already exist) the table is created as expected.
If I run the script again I get the following error:
Statement failed, SQLCODE = -607
unsuccessful metadata update
-STORE RDB$RELATIONS failed
-deadlock
After line 8 in file d:\myscript.sql
When the script exits, MYTABLE has been deleted and can no longer be found in the database.
If I run the script a third time the table is once again created and no errors are thrown.
Why can't the script both delete and then recreate a table?
DDL from PSQL is not allowed, using EXECUTE STATEMENT it is not directly forbidden, and usually possible, but still not wise exactly because of these kinds of problems. I am not exactly sure about the reasons, but part of it have to do with how DDL changes are applied in Firebird; the use of execute statement adds additional locks iirc which conflict with a subsequent DDL for the same table name.
Instead of dropping and creating this way, you should use the DDL statement RECREATE TABLE instead.
Note that the word deadlock in this error is actually a bit of a misnomer (there is no real deadlock).

How Liquibase rollback when execution failed?

If i run change log file that contain multiple change set from command line and it failed because of wrong sql at say change set 2. So change set 1 has executed and committed then how will i rollback this change using liquibase.
The easiest would be to use the rollbackCount command. Running "liquibase rollbackCount 1" will roll back the last changeSet executed using either the specified <rollback> block in the changeSet or by figuring it out if Liquibaes can based on the information in the changeSet. For example, a createTable command has the information needed to create a drop table statement, but a dropTable command does not have the information needed to do a create table so you would need to specify your own rollback block.

Error In Database Renaming

I need to rename one of my database and tried a query like this
ALTER DATABASE Test MODIFY NAME = NewTest
But this throws an error
Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.
Can any one give me any suggestion?
Try something like;
USE master
GO
ALTER DATABASE Test
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE Test MODIFY NAME = NewTest
GO
ALTER DATABASE NewTest
SET MULTI_USER
GO
Be aware of the fact that this may not rename the physical file on the hard drive though.
There are a couple of things you need to investigate. The reason you're getting that error could be due to one or more of the following things:
The account you're using does not have permission to run the command
The DB is locked by another process/user
The database contains a file group that is read-only
You can try and force single user mode to check 2.
ALTER DATABASE SINGLE_USER ROLLBACK IMMEDIATE.
That will kill any concurrent connections to the DB allowing you to rule out number two.
You have two options:
Look for and kill all connections like OMG Priories suggest
Open the database in Single Server Mode as described here:
http://technet.microsoft.com/en-us/library/ms345598(v=sql.105).aspx