I'm trying yo create a table unfortunately i'm getting an error.
Here is the query that i'm running:
CREATE TABLE UpStreamParam (
macaddress CHAR(20),
datats BIGINT,
cmtstimestamp BIGINT,
modulation INT,
chnlidx INT,
severity BIGINT,
rxpower FLOAT,
sigqnoise FLOAT,
noisedeviation FLOAT,
prefecber FLOAT,
uncorrectables BIGINT)
STORED AS ORC tblproperties ("orc.compress"="SNAPPY", "orc.bloom.filter.columns"="macaddress")
LOCATION '/usr/hive/warehouse/UpStreamParam'
PARTITIONED BY(cmtsid CHAR(50), date int);
This is the error that i'm getting
ERROR: syntax error at or near "STORED"
LINE 21: STORED AS ORC tblproperties ("orc.compress"="SNAPPY", "orc.b...
Any idea how to solve it?
I have version 8.4.20
You must eliminate this part:
STORED AS ORC tblproperties ("orc.compress"="SNAPPY", "orc.bloom.filter.columns"="macaddress")
LOCATION '/usr/hive/warehouse/UpStreamParam'
PARTITIONED BY(cmtsid CHAR(50), date int);
since these kinds of physical storage specifications are not allowed in PostgreSQL. See the Create Table page.
Related
I am trying to create a Hive table with partitions but getting the above error. What am I doing wrong?
CREATE TABLE IF NOT EXISTS schema.table_name
(
ID varchar(20),
name varchar(50)
)
PARTITIONED BY (part_dt varchar(8), system varchar(5));
The code works without the partitioning clause. Something gives up during partitioning.
Statement is working in hive. Pls find below screenshot.
Its possible that some of column names are reserved keywords and that is throwing error. if yes, you can use below SQL too.
CREATE TABLE IF NOT EXISTS schema.table_name
(
`ID` varchar(20),
`name` varchar(50)
)
PARTITIONED BY (`part_dt` varchar(8), `system` varchar(5));
CREATE EXTERNAL TABLE schema_vtvs_ai_ext.fire(
fire_number VARCHAR(50),
fire_year DATE,
assessment_datetime INTEGER,
size_class CHAR,
fire_location_latitude REAL,
fire_location_longitude REAL,
fire_origin VARCHAR(50),
general_cause_desc VARCHAR(50),
activity_class VARCHAR(50),
true_cause VARCHAR(50),
fire_start_date DATE,
det_agent_type VARCHAR(50),
det_agent VARCHAR(50),
discovered_date DATE,
reported_date DATE,
start_for_fire_date DATE,
fire_fighting_start_date DATE,
initial_action_by VARCHAR(50),
fire_type VARCHAR(50),
fire_position_on_slope VARCHAR(50),
weather_conditions_over_fire VARCHAR(50),
fuel_type VARCHAR(50),
bh_fs_date DATE,
uc_fs_date DATE,
ex_fs_date DATE
);
This is the SQL code i have written to add an external table in Redhsift schema but the below error. i can't seem to see where the error is?
[Amazon](500310) Invalid operation: syntax error at end of input Position: 684;
If your data is in Amazon S3, then you need to specify the file format (via STORED AS) and the path to data files in S3 (via LOCATION).
This is the example query for csv files (with 1 line header):
create external table <external_schema>.<table_name> (...)
row format delimited
fields terminated by ','
stored as textfile
location 's3://mybucket/myfolder/'
table properties ('numRows'='100', 'skip.header.line.count'='1');
See official doc for details.
I'm trying to creat an external table in Hive with this
CREATE EXTERNAL TABLE IF NOT EXISTS 1987(
YEAR INT,
MONTH INT,
DAYOFMONTH INT,
DAYOFWEEK INT,
DEPTIME INT,
CRS INT,
ARRTIME TIME,
CARRIER STRING,
FLIGHTNUM INT,
TAILNUM STRING,
ACTUALELAPSED INT,
CRSELAPSED INT,
AIRTIME INT,
ARRDELAY INT,
DEPDELAY INT,
ORIGIN STRING,
DEST STRING,
DISTANCE INT,
TAXIIN INT,
TAXIOUT INT,
CANCELLED INT,
CANCELLATIONCODE STRING,
DIVERTED INT,
CARRIERDELAY INT,
WEATHERDELAY INT,
NASDELAY INT,
SECURITYDELAY INT,
LATEAIRCRAFT INT,
Origin CHAR(1))
COMMENT 'A??O 1987'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
location '/user/raj_ops/PROYECTO/'1987.csv';
But get the following error:
org.apache.hive.service.cli.HiveSQLException: Error while compiling
statement: FAILED: ParseException line 1:36 cannot recognize input
near '1987' '(' 'YEAR' in table name
Anyone knows why?
Thanks :)
location should be '/user/raj_ops/PROYECTO/' (without file itself). If you have other files in the same location then move them to separate locations, like /user/raj_ops/PROYECTO/1987/ for 1987. Because table can be built on top of location, not file.
And table name cannot start with digits. use backquotes 1987 or rename it like year_1987
I think you probably need to escape the table name with back-ticks if its numeric:
`1987`
There is an extra quote in the location value.Remove that.
location '/user/raj_ops/PROYECTO/'1987.csv';
Should be
location '/user/raj_ops/PROYECTO/1987.csv';
I'm just wondering if anyone has created or heard of a function to guess the appropriate data type of data stored in a SQLServer table as VarChar.
I'm working on an SSIS package that you can point at a directory, and it will loop through and create tables / import data for every CSV that exists it. I'm having trouble with specifying the data types before import, so as a work around I would like to import all the data as VarChar(50) into a temporary table and then run some sort of function to analyze each column for the appropriate data type (int, decimal, float, etc) so I can use that to script the create table and insert statements.
So for example I'd like to be able to point a function or query at this temp table
CREATE TABLE [#Data]
(
[ProductCode] varchar(50),
[ProductName] varchar(50),
[Year] varchar(50),
[Total_volume] varchar(50),
[Total_Quantity] varchar(50),
[PercentSold] varchar(50)
)
to read through the data and determine what data type / length is most appropriate - much like the 'Suggest Data Type' tool in Excel Connection Manager does, only something I can tie into a variable to be done dynamically. It should end up looking something like
CREATE TABLE [Data]
(
[ProductCode] varchar(6),
[ProductName] varchar(11),
[Year] int,
[Total_volume] int,
[Total_Quantity] int,
[PercentSold] decimal(3,2)
)
Any thoughts?
Thanks!
I have a client using SQL 2008R2 and they have Merge replication in place. They have hit the max range on a few of their tables because the subscriptions were being removed and readded multiple times. The table on the publisher only contains 175000 row and is replicating to 7 other sites so they should be no where close to hitting the max.
How can I reseed the table and keep all the data intact? I tried copying the table and then dropping the table and renaming it but the identity ranges values stay the same. I cannot change the data type because the uses of Int as a datatype is hard coded into our software.
Any help would be appreciated.
Table looks like this and the rownum is the id column.
rowguid, uniqueidentifier,
,contactid, float,
,RowNum, int,
,type, int,
,createdby, varchar(30),
,assignedto, varchar(30),
,createddate, int,
,modifieddate, int,
,startdate, int,
,duedate, int,
,completedate, int,
,duration, int,
,tickler, int,
,priority, smallint,
,therule, int,
,status, int,
,private, tinyint,
,flags, int,
,subject, int,
,notes, text