Hive query error encountered near token TOK_TMP_FILE - hive

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.

Related

Oracle display all sql query run against DB by application

I have an old appliation/executable that loads data to Oracle DB that we are reverse engineering. We'd like to see all the sql generated by the application without stepping through source code. The source code has many different versions and may not match the executable.
select v$sql.last_load_time, v$sql.sql_text
from v$sql
order by v$sql.last_load_time desc
First, you will need help from DBA to:
grant permission to select from table v$sql.
ALTER SYSTEM SET sql_trace = true SCOPE=MEMORY; when done
ALTER SYSTEM SET sql_trace = false SCOPE=MEMORY;
select sid, serial#, machine from sys.v_$session ; find the sid and serial# for your machine and input to the next command
execute sys.dbms_system.set_sql_trace_in_session(sid, serial#, true);
flush the cache by executing following commands:
alter system flush buffer_cache;
alter system flush shared_pool;

Error when using the MERGE command in DB2

I'm trying to update or insert data into a table using the MERGE command in DB2 v11. However I keep getting the error:
SQL0723N An error occurred in a triggered SQL statement in trigger "TRACE_AFTE".
Information returned for the error includes SQLCODE "-746", SQLSTATE "57053" and message tokens
"CUSTOM_AFTER_UPDAT|SP_CUSTOM_AFTER_U". SQLSTATE=09000"
I looked up the error and it said that the routine conflicted with the use of the table..that the table is already in use.
I've tried changing the query to update based on VALUES instead of table but get an error on an unexpected token
SQL0104N An unexpected token "INSERT" was found following "MATCHED THEN".
Expected tokens may include: "". SQLSTATE=42601
"
MERGE INTO TRACE target
USING IMPORT_RAW source
ON target.DETAIL_NUMBER = source.DETAIL_LINE_ID
AND target.DESC = source.TRACE_TYPE
WHEN MATCHED THEN
UPDATE SET NUMBER = source.PRO
With VALUES
MERGE TRACE AS T
USING IMPORT_RAW AS S
ON (T.DETAIL_NUMBER= S.DETAIL_LINE_ID) AND T.DESC = S.TRACE_TYPE
WHEN NOT MATCHED BY TARGET
THEN INSERT(DETAIL_NUMBER, TRACE_NUMBER) VALUES(S.DETAIL_LINE_ID, S.CARRIER_PRO)
WHEN MATCHED
THEN UPDATE SET T.NUMBER= S.PRO;
The query should update multiple records from the Import_raw table where the record exists and import where it doesn't.
What am I doing wrong?
Thanks for the help. It seems like the problem was that it was trying to merge the same record twice. My truncate table had been commented out.

Copy Table from a Server and Insert into another Server: What is wrong with this T-SQL query?

I am using SQL Server 2014. I have created the following T-SQL query which I uploaded to my local SQL server to run as a job process on a daily basis at a specific time. However, I noticed that it failed to run. If I run it manually in SSMS, it runs correctly.
What is preventing the query to run as an automated process? Is it a syntax issue?
USE MyDatabase
GO
DELETE FROM ExchangeRate -- STEP 1
;WITH MAINQUERY_CTE AS ( --STEP 2
SELECT *
FROM (
SELECT *
FROM [178.25.0.20].HMS_ARL.dbo.ExchangeRate
) q
)
INSERT INTO ExchangeRate --STEP 3
SELECT *
FROM MAINQUERY_CTE
Basically, the function of the query is to copy a table named ExchangeRate from the live server and paste its content in a table of the same name (which already exists on my local server).
Error Log shows the following message:
Description: Executing the query "USE MyDatabase DELETE FROM
ExchangeRate..." failed with the following error: "Access to the
remote server is denied because no login-mapping exists.". Possible
failure reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly. End Error DTExec: The package execution returned
DTSER_FAILURE (1). Started: 10:59:30 AM Finished: 10:59:30 AM
Elapsed: 0.422 seconds. The package execution failed. NOTE: The
step was retried the requested number of times (3) without succeeding.
The step failed.
May be you have to create Linked Server in your local server to the Remote server?

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).

Not able to create Materialized query on AS400

I get an error message when trying to create materialized query in as400
I use winSql for the connection.
The syntax seems valid.
Could you please point out what am I doing wrong?
This is the statement I am trying to execute
CREATE TABLE AAA.TEST_MQ AS
(
SELECT test.*
FROM
AAA.TABLE_NAME test
) REFRESH DEFERRED
This is the error message:
Error: SQL0104 - Token <END-OF-STATEMENT> was not valid. Valid tokens: IMMEDIATE <IDENTIFIER>. (State:37000, Native Code: FFFFFF98)
I Tried creating an immediate one as well.
Try this:
CREATE TABLE AAA.TEST_MQ AS (
SELECT test.*
FROM
AAA.TABLE_NAME test )
DATA INITIALLY DEFERRED
REFRESH DEFERRED
MAINTAINED BY USER
ENABLE QUERY OPTIMIZATION
;
I use JaySQL Lite and it works.