Rename Hive schema/database - hive

I'm using Hive 2.1.1 - and I need to rename one of my schemas.
I tried this command: ALTER SCHEMA name RENAME TO new_name;
But got this error back: FAILED: ParseException line 1:13 cannot recognize input near 'name' 'RENAME' 'TO' in alter database statement.
Does anyone know can I rename my schema?
Thanks!!

Related

Truncating tables in Azure Data Factory Pre-Copy script?

I am building a pipeline, and now I need to truncate my destination tables in azure sql db, but before that I need to truncate the destination tables. but I can't figure out the script:
Click to view the ADF screenshot for SINK settings
instead, I put this code but that is wrong because it runs before every copy of the tables (5 times) and truncates all the table except the last one. so I need to make it parameterized I guess:
*truncate table [dbo].[Global_data.csv]
truncate table [dbo].[Option_data.csv]
truncate table [dbo].[State_data.csv]
truncate table [dbo].[Status_data.csv]
truncate table [dbo].[Target_data.csv]*
Also please see my source parameters:
**ADLSv2 container: #pipeline().parameters.SourceContainer
ADLSv2 Directory: #pipeline().parameters.SourceDirectory
ADLSv2 filename: #item().name
Sink TableName: #item().name**
So I'm guessing that my pre-script must be something like:
truncate table #item().name but this resulted an error for me:
Error Screenshot
DetailsErrorCode= SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Incorrect syntax near '#item'.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Incorrect syntax near '#item'.,Source=.Net SqlClient Data Provider,SqlErrorNumber=102,Class=15,ErrorCode=-2146232060,State=1,Errors=[{Class=15,Number=102,State=1,Message=Incorrect syntax near '#item'.,},],'
when I use TRUNCATE TABLE [#{item()}] , I get below error 5 times (one for each table accordingly):
ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Cannot find the object "{"name":"StateMetadata.csv","type":"File"}" because it does not exist or you do not have permissions.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Cannot find the object "{"name":"StateMetadata.csv","type":"File"}" because it does not exist or you do not have permissions.,Source=.Net SqlClient Data Provider,SqlErrorNumber=4701,Class=16,ErrorCode=-2146232060,State=1,Errors=[{Class=16,Number=4701,State=1,Message=Cannot find the object "{"name":"StateMetadata.csv","type":"File"}" because it does not exist or you do not have permissions.,},],'
Please use truncate table TRUNCATE TABLE [#{item().name}]

How can I add a geometry column in using pgAdmin?

The following is the scripts I was using:
ALTER TABLE locations ADD COLUMN geom geometry(PointZ,4326);
I got this error:
ERROR: type "geometry" does not exist
LINE 1: ALTER TABLE steven_requests ADD COLUMN geom geometry(PointZ,...
^
SQL state: 42704
Character: 45
Thank you!
I found the way to deal with this extension:
I went into the application folder on my mac, then I opened the Postgresql folder, and then opened "Application stack builder"; from there, I was able to install the PostGIS extension.
Finally, this query was able to work:
ALTER TABLE locations ADD COLUMN geom geometry(PointZ,4326);

Hive truncate external table with force command not working

I was able to truncate external table using force command in one environment, but in another it was not working and throwing error.
TRUNCATE TABLE hive_table_name FORCE
org.apache.hive.service.cli.HiveSQLException: Error while compiling
statement: FAILED: ParseException line 1:24 extraneous input 'FORCE'
expecting EOF near '
please help if we need to configure something

how to add a txt file into database table in netbeans

i want to add some data's into a table in netbeans. i have the values in .txt and .xls format. is there any way to insert it into the table.?
i found this link to do the work.
Link
but it showed an error when i performed this code
Create or Replace Directory cre_dir as 'C:\Users\Srinivasan\Desktop\SQL';
Error
Error code -1, SQL state 42X01: Syntax error: Encountered "OR" at line 1, column 8.
what is the mistake am i making here..?
You need to grant the CREATE DIRECTORY privilege to the user you are using or the user has to have DBA privilege
The path you are specifying must exists.
Read more about directories here

Hadoop Hive: create external table with dynamic location

I am trying to create a Hive external table that points to an S3 output file.
The file name should reflect the current date (it is always a new file).
I tried this:
CREATE EXTERNAL TABLE s3_export (...)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
LOCATION concat('s3://BlobStore/Exports/Daily_', from_unixtime(unix_STRING(),'yyyy-MM-dd'));
but I get an error:
FAILED: Parse Error: line 3:9 mismatched input 'concat' expecting StringLiteral near 'LOCATION' in table location specification
is there any way to dynamically specify table location?
OK, I found the hive variables feature.
So I pass the location in the cli as follows
hive -d s3file=s3://BlobStore/Exports/APKsCollection_test/`date +%F`/
and then use the variable in the hive command
CREATE EXTERNAL TABLE s3_export (...)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
LOCATION '${s3File}';
This function doesn't work at my side ,
how did you make this happen ?
hive -d s3file=s3://BlobStore/Exports/APKsCollection_test/`date +%F`/