This query works fine in Athena's front-end:
SELECT * FROM analysisdata."iris" limit 10;
I am using this Python code to run the above query via Python/pyathena
from pyathena import connect
cursor = connect(aws_access_key_id='AKI.DELETED.2Q',
aws_secret_access_key='D.DELETED.Al',
s3_staging_dir='s3://Bla887342ac-a3ce-4600-94d0-9092f4a6bd20/Iris',
region_name='eu-west-1').cursor()
cursor.execute("""SELECT * FROM analysisdata.""iris"" limit 10;""")
print(cursor.description)
print(cursor.fetchall())
Unfortunately I get:
pyathena.error.DatabaseError: An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: line 1:27: mismatched input '.' expecting {<EOF>, ',', 'WHERE', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'APPROXIMATE', 'JOIN', 'CROSS', 'INNER', 'LEFT', 'RIGHT', 'FULL', 'NATURAL', 'UNION', 'EXCEPT', 'INTERSECT'}
I presume is my introduction of:
""" and ""
Any ideas?
PS:
I tried:
cursor.execute("SELECT * FROM analysisdata.""iris"" limit 10;")
get:
pyathena.error.OperationalError: com.facebook.presto.hive.DataCatalogException: Namespace analysisdata not found. Please check your query.
Why does facebook appear in this?
I also tried:
cursor.execute("SELECT * FROM analysisdata.iris limit 10;")
same error message ...
Athena queries data directly from Amazon S3 so there's no data movement or loading required. Simply define your schema using DDL statements and start querying your data right away.
With the federated query functionality in Athena, you can now run SQL queries across data stored in relational, non-relational, object, and custom data sources and store the results back in Amazon S3 for further analysis.
Configure RDS as Data Source. You configure PostgreSQL RDS instance as the data source for Amazon Athena so that you can query RDS data from the Athena Query Editor. Goto Athena Management console and click on Data sources link.
The following considerations apply to creating and using views in Athena: In Athena, you can preview and work with views created in the Athena Console, in the AWS Glue Data Catalog, if you have migrated to using it, or with Presto running on the Amazon EMR cluster connected to the same catalog.
As it appears, your catalog in eu-west-1 does not contain analysisdata db.
You have to specify the region in which you created the database/table in Athena Console, rather than the specified S3 bucket region.
To solve that, log into the console, and verify which region contains your database/table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With