public final class CreateTableLocationRecovery extends Object
Athena creates tables with Hive DDL, as in CREATE EXTERNAL TABLE events (...) PARTITIONED BY (...)
STORED AS PARQUET LOCATION 's3://bucket/events/'. The Athena grammar reads the column list but none of the
clauses after it, so the general create-table error recovery ignores those clauses and parses the statement
again. LOCATION names the files of the table, which lineage shows as the path the table comes from, as it
does for Hive. This recovery reads it before the clauses are ignored and gives it to the parsed statement, so
that TCreateTableSqlStatement.getTableLocation() returns it as it does for Hive.
Used by both parse paths, TGSqlParser and the vendor SqlParser, so that they recover in the
same way. Not intended for use outside the parser.
| Modifier and Type | Method and Description |
|---|---|
static TSourceToken |
locationAfterColumnList(TSourceTokenList tokens,
int locationKeyword)
The string of the LOCATION clause after the column list of a CREATE TABLE:
's3://bucket/events/' in
CREATE EXTERNAL TABLE events (...) STORED AS PARQUET LOCATION 's3://bucket/events/'. |
static void |
setLocation(TCustomSqlStatement stmt,
TSourceToken location,
EDbVendor vendor)
Gives the location found by
locationAfterColumnList(gudusoft.gsqlparser.TSourceTokenList, int) to the statement that the recovery parsed again. |
public static TSourceToken locationAfterColumnList(TSourceTokenList tokens, int locationKeyword)
's3://bucket/events/' in
CREATE EXTERNAL TABLE events (...) STORED AS PARQUET LOCATION 's3://bucket/events/'. Only a clause at
parenthesis depth zero counts, so a string in a property list, such as
TBLPROPERTIES ('location' = '...'), is not one. Read the tokens before the recovery ignores them.tokens - the tokens of one CREATE TABLE statementlocationKeyword - the lexer's token code of the keyword LOCATION, 0 when the lexer has nonepublic static void setLocation(TCustomSqlStatement stmt, TSourceToken location, EDbVendor vendor)
locationAfterColumnList(gudusoft.gsqlparser.TSourceTokenList, int) to the statement that the recovery parsed again.
Nothing happens when location is null or the statement is not a CREATE TABLE.