Problem
Using LATERAL VIEW in a Presto query returns the following error message:
An error occurred while calling o23.execute. : java.sql.SQLException: Query failed (#20180913_174414_02563_3tbfv): Unable to get table schema. TRecordServiceException(code:INVALID_REQUEST, message:Could not plan request., detail:AnalysisException: Could not resolve column/field reference: 'r.xx_yyy_zzzzzzz' )
at com.facebook.presto.jdbc.PrestoResultSet.resultsException(PrestoResultSet.java:1802)
...
at java.lang.Thread.run(Thread.java:748) Caused by: com.facebook.presto.spi.PrestoException: Unable to get table schema. TRecordServiceException(code:INVALID_REQUEST, message:Could not plan request., detail:AnalysisException: Could not resolve column/field reference: 'r.xx_yyy_zzzzzzz' )
...
1 more Caused by: com.cloudera.recordservice.core.RecordServiceException: TRecordServiceException(code:INVALID_REQUEST, message:Could not plan request., detail:AnalysisException: Could not resolve column/field reference: 'r.xx_yyy_zzzzzzz' )
...
17 more Caused by: com.cloudera.recordservice.thrift.TRecordServiceException: Could not plan request.
...
Answer
External Views in Okera honor LATERAL VIEW as implemented in HiveQL. The key statements shown in the stack trace above complain of an INVALID_REQUEST, indicating the issue is with Presto rather than Okera.
The LATERAL VIEW function depends on a user-defined function, such as explode(), to generate tables that include a complex data type, such as an array. The user can request a LATERAL VIEW to expand the type, i.e., show each array element in a separate record.
Presto uses UNNEST to expand arrays and maps. It is similar enough to Hive's LATERAL VIEW that most rewrites are straightforward. Some simple examples are given in Presto's documentation for migrating Hive queries:
https://prestodb.io/docs/current/migration/from-hive.html
Comments
0 comments
Please sign in to leave a comment.