简体   繁体   中英

Not able to fetch records from mongodb using presto

I have a mongodb catalog under etc/catalog named mongodb.properties When I run the presto shell and execute command : Show tables; I shows the collections of mongodb but when I run select query it gives me errors.

presto> select * from <catalog>.<schema>.<collection/table>;
Gives error :
java.sql.SQLException: Query failed (#20190429_125534_00001_qxggq): line 1:8: SELECT * not allowed in queries without FROM clause
at io.prestosql.jdbc.PrestoResultSet.resultsException(PrestoResultSet.java:1839)
at io.prestosql.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1749)
at io.prestosql.jdbc.PrestoResultSet.<init>(PrestoResultSet.java:118)
at io.prestosql.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:251)
at io.prestosql.jdbc.PrestoStatement.execute(PrestoStatement.java:229)
at io.prestosql.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:78)
at spark_mongo_poc.SparkMongo.process_query(SparkMongo.java:32)
at spark_mongo_poc.SparkMongo.main(SparkMongo.java:76)

Presto> select name from <mongodb>.<schema>.<collection>;
Gives error :
java.sql.SQLException: Query failed (#20190429_125718_00002_qxggq): line 1:8: Column 'name' cannot be resolved
at io.prestosql.jdbc.PrestoResultSet.resultsException(PrestoResultSet.java:1839)
at io.prestosql.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1749)
at io.prestosql.jdbc.PrestoResultSet.<init>(PrestoResultSet.java:118)
at io.prestosql.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:251)
at io.prestosql.jdbc.PrestoStatement.execute(PrestoStatement.java:229)
at io.prestosql.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:78)
at spark_mongo_poc.SparkMongo.process_query(SparkMongo.java:32)
at spark_mongo_poc.SparkMongo.main(SparkMongo.java:76)

I want same data as we get when we do db.collection.find({}); which gives me proper result in the form of documents

Please help

  • I Fixed the above issue by just changing the mongodb collection name
    to all Lower Case. There is an issue with presto mongodb catalog that it doesnot recognise Upper case Lettered collection name and that was the reason it was not able to identify the collection. So I changed my collection case to lower and it started working. :)

I had similar issue. I fixed it adding this to catalog configuration.

mongodb.case-insensitive-name-matching=true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM