I used this as a reference to create a Create statement that creates an Apache Iceberg table in Amazon Athena's Query Editor. Below.
CREATE TABLE iceberg_table (id int, data string, category string)
PARTITIONED BY (category, bucket(16, id))
LOCATION 's3://xxxxxxxx/iceberg_table/'
TBLPROPERTIES (
'table_type' = 'ICEBERG',
'format' = 'parquet',
'write_target_data_file_size_bytes' = '536870912'
)
When I ran this, I got the following error.
Iceberg cannot found the requested entity
Also, when I ran Explain, I got the following message
line 2:1: mismatched input 'PARTITIONED'. Expecting: 'COMMENT', 'WITH', <EOF>
So, I think there is a problem with the Create statement I created.
I checked to see if extra spaces had been removed or if the quotes were incorrect, but could not find the cause.
I would appreciate your help.
Thanks.
The code works fine for me. I'm using Athena with Engine v3, maybe that's the cause?
Related
I'm writing a Java application to automatically build and run SQL queries. For many tables my code works fine but on a certain table it gets stuck by throwing the following exception:
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "continent" does not exist
Hint: Perhaps you meant to reference the column "countries.Continent".
Position: 8
The query that has been run is the following:
SELECT Continent
FROM network.countries
WHERE Continent IS NOT NULL
AND Continent <> ''
LIMIT 5
This essentially returns 5 non-empty values from the column.
I don't understand why I'm getting the "column does not exist" error when it clearly does in pgAdmin 4. I can see that there is a schema with the name Network which contains the table countries and that table has a column called Continent just as expected.
Since all column, schema and table names are retrieved by the application itself I don't think there has been a spelling or semantical error so why does PostgreSQL cause problems regardless? Running the query in pgAdmin4 nor using the suggested countries.Continent is working.
My PostgreSQL version is the newest as of now:
$ psql --version
psql (PostgreSQL) 9.6.1
How can I successfully run the query?
Try to take it into double quotes - like "Continent" in the query:
SELECT "Continent"
FROM network.countries
...
In working with SQLAlchemy environment, i have got this error with the SQL like this,
db.session.execute(
text('SELECT name,type,ST_Area(geom) FROM buildings WHERE type == "plaza" '))
ERROR: column "plaza" does not exist
Well, i changed == by = , Error still persists, then i interchanged the quotes, like follows. It worked. Weird!
....
text("SELECT name,type,ST_Area(geom) FROM buildings WHERE type = 'plaza' "))
This problem occurs in postgres because the table name is not tablename instead it is "tablename".
for eg.
If it shows user as table name,
than table name is "user".
See this:
Such an error can appear when you add a space in the name of a column by mistake (for example "users ").
QUICK FIX (TRICK)
If you have recently added a field which you have already deleted before and now trying to add the same field back then let me share you this simple trick! i did this and the problem was gone!!
so, now just delete the migration folder entirely on the app,then instead of adding that field you need to now add a field but with the name of which you have never declared on this app before, example if you are trying to add title field then create it by the name of heading and now do the migration process separately on the app and runserver, now go to admin page and look for that model and delete all the objects and come to models back and rename the field that you recently made and name it to which you were wishing it with earlier and do the migrations again and now your problem must have been gone!!
this occurs when the objects are there in the db but you added a field which wasn't there when the earlier objs were made, so by this we can delete those objs and make fresh ones again!
I got the same error when I do PIVOT in RedShift.
My code is similar to
SELECT *
INTO output_table
FROM (
SELECT name, year_month, sales
FROM input_table
)
PIVOT
(
SUM(sales)
FOR year_month IN ('nov_2020', 'dec_2020', 'jan_2021', 'feb_2021', 'mar_2021', 'apr_2021', 'may_2021', 'jun_2021', 'jul_2021', 'aug_2021',
'sep_2021', 'oct_2021', 'nov_2021', 'dec_2021', 'jan_2022', 'feb_2022', 'mar_2022', 'apr_2022', 'may_2022', 'jun_2022',
'jul_2022', 'aug_2022', 'sep_2022', 'oct_2022', 'nov_2022')
)
I tried year_month without any quote (got the error), year_month with double quote (got the error), and finally year_month with single quote (it works this time). This may help if someone in the same situation like my example.
Here is my Athena Query. I am trying to add a partition to a table:
ALTER TABLE public_data_scraping_yahoo_finance_pricing_table
ADD PARTITION ("S3_DATE" = '2021-07')
LOCATION 's3://my-bucket/enriched_data/pricing/2021-07/';
I'm following the documentation as seen here. But I'm getting some sort of syntax error.
When I run it I get:
line 2:5: mismatched input 'partition'. expecting: '.', 'add' (service: amazonathena; status code: 400; error code: invalidrequestexception; request id: 8dd2f1ac-d197-4c4c-b2fc-024383fd30fb; proxy: null)
I have run other queries to add partitions before, and have never had this issue. I would expect this query to create the partition without any issues.
Is someone able to help me identify the issue?
Can you try to remove the quotes from the table name? This fixed this error for me when trying to remove partitions
Okay so it turns out the issue was because the partition field I was specifying was wrapped in double quotes "S3_DATE" when it shouldn't be.
So the correct query would be:
ALTER TABLE public_data_scraping_yahoo_finance_pricing_table
ADD PARTITION (S3_DATE='2021-07')
LOCATION 's3://my-bucket/enriched_data/pricing/2021-07/';
I want to execute the following SQL statement on BigQuery:
create table TMSPCBTDZOP000(
ART_ID VARCHAR(18),
LND_ID VARCHAR(3),
ART__BEZ VARCHAR(60),
ART_ANZ_ID VARCHAR(18))
I got the following error message:
Error: Syntax error: Expected ")" or "," but got "(" at [2:24]
I tried both legacy and standard SQL.
We are currently trying to use BigQuery as a data source for our reporting software (MicroStrategy) and it fails with the error shown above. The same error appears if I directly fire this SQL statement in bq. How can I fix this?
VARCHAR is not a supported data type; see the data types documentation. Use STRING instead:
create table TMSPCBTDZOP000 (
ART_ID STRING,
LND_ID STRING,
ART__BEZ STRING,
ART_ANZ_ID STRING
)
You need to use standard SQL for this, and you probably need to qualify TMSPCBTDZOP000 with the name of the dataset, e.g. dataset.TMSPCBTDZOP000.
I think you are looking something like mentioned in old thread here
Create table SQL syntax in Google Bigquery
I found it useful and this may help you how to create a table in bigquery.
Cheers,
I'm writing a Java application to automatically build and run SQL queries. For many tables my code works fine but on a certain table it gets stuck by throwing the following exception:
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "continent" does not exist
Hint: Perhaps you meant to reference the column "countries.Continent".
Position: 8
The query that has been run is the following:
SELECT Continent
FROM network.countries
WHERE Continent IS NOT NULL
AND Continent <> ''
LIMIT 5
This essentially returns 5 non-empty values from the column.
I don't understand why I'm getting the "column does not exist" error when it clearly does in pgAdmin 4. I can see that there is a schema with the name Network which contains the table countries and that table has a column called Continent just as expected.
Since all column, schema and table names are retrieved by the application itself I don't think there has been a spelling or semantical error so why does PostgreSQL cause problems regardless? Running the query in pgAdmin4 nor using the suggested countries.Continent is working.
My PostgreSQL version is the newest as of now:
$ psql --version
psql (PostgreSQL) 9.6.1
How can I successfully run the query?
Try to take it into double quotes - like "Continent" in the query:
SELECT "Continent"
FROM network.countries
...
In working with SQLAlchemy environment, i have got this error with the SQL like this,
db.session.execute(
text('SELECT name,type,ST_Area(geom) FROM buildings WHERE type == "plaza" '))
ERROR: column "plaza" does not exist
Well, i changed == by = , Error still persists, then i interchanged the quotes, like follows. It worked. Weird!
....
text("SELECT name,type,ST_Area(geom) FROM buildings WHERE type = 'plaza' "))
This problem occurs in postgres because the table name is not tablename instead it is "tablename".
for eg.
If it shows user as table name,
than table name is "user".
See this:
Such an error can appear when you add a space in the name of a column by mistake (for example "users ").
QUICK FIX (TRICK)
If you have recently added a field which you have already deleted before and now trying to add the same field back then let me share you this simple trick! i did this and the problem was gone!!
so, now just delete the migration folder entirely on the app,then instead of adding that field you need to now add a field but with the name of which you have never declared on this app before, example if you are trying to add title field then create it by the name of heading and now do the migration process separately on the app and runserver, now go to admin page and look for that model and delete all the objects and come to models back and rename the field that you recently made and name it to which you were wishing it with earlier and do the migrations again and now your problem must have been gone!!
this occurs when the objects are there in the db but you added a field which wasn't there when the earlier objs were made, so by this we can delete those objs and make fresh ones again!
I got the same error when I do PIVOT in RedShift.
My code is similar to
SELECT *
INTO output_table
FROM (
SELECT name, year_month, sales
FROM input_table
)
PIVOT
(
SUM(sales)
FOR year_month IN ('nov_2020', 'dec_2020', 'jan_2021', 'feb_2021', 'mar_2021', 'apr_2021', 'may_2021', 'jun_2021', 'jul_2021', 'aug_2021',
'sep_2021', 'oct_2021', 'nov_2021', 'dec_2021', 'jan_2022', 'feb_2022', 'mar_2022', 'apr_2022', 'may_2022', 'jun_2022',
'jul_2022', 'aug_2022', 'sep_2022', 'oct_2022', 'nov_2022')
)
I tried year_month without any quote (got the error), year_month with double quote (got the error), and finally year_month with single quote (it works this time). This may help if someone in the same situation like my example.
I am trying to create an external table in Informix.
create external table test_table(cols varchar(10))
using ( datafiles('C:/sample.txt'), format 'delimited', deluxe);
But it gives me an error :
[Error Code: -26174, SQL State: IX000] Incorrect DATAFILE entry C:/sample.txt.
Can anyone suggest me the right syntax for path entry...
I have also tried.
load from "C:\sample.txt" insert into test_table;
Which gives me a syntax error. Any help is greatly appreciated!!
About the create external table
Did you check the correct syntax at the manual? (here)
At datafiles keyword, you don't use the correct syntax.
This probably will work.
create external table test_table(cols varchar(10))
using ( datafiles('DISK:C:\sample.txt'), format 'delimited', deluxe);
About the load
It isn't a native command from the engine, is a specific command of dbaccess utility.
So, if you aren't using dbaccess, it will not work.
BTW, the syntax of your load is correct...