public final class CreateTableAsSelectRecovery extends Object
CREATE TABLE ... AS SELECT whose table clauses
the grammar cannot read.
When a CREATE TABLE fails to parse, the general recovery ignores everything after the first
closing parenthesis at depth zero and parses the statement again, so a table whose column list
is followed by an unsupported option still yields its columns. For a CREATE TABLE AS SELECT that
ignores the query too, and with it every lineage edge of the statement, while the statement
reports success. When the first closing parenthesis belongs to an option, as in
DUPLICATE KEY(k1), or to the query itself, the result is a query cut short.
This recovery keeps the header and the query and ignores only the table clauses between
them: CREATE TABLE t DUPLICATE KEY(k1) DISTRIBUTED BY HASH(k1) AS SELECT ... is parsed as
CREATE TABLE t AS SELECT .... When nothing stands between the header and the query, the
error lies in one of them and is kept.
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 boolean |
ignoreClausesBeforeQuery(TSourceTokenList tokens,
int queryStart)
Ignores the table clauses between the header and the query, so that the grammar reads both
even when it cannot read a clause in between (an OLAP key, a partition or distribution
clause, properties, ...).
|
static int |
queryStart(TSourceTokenList tokens)
Position of the AS that starts the query of a CREATE TABLE AS SELECT: the first AS at
parenthesis depth zero that is followed by SELECT, WITH or an opening parenthesis, or -1 when
the statement has no query.
|
public static int queryStart(TSourceTokenList tokens)
k2 INT AS k1 + 1) sits inside the
column list, one level deep, so it is never taken for the query.tokens - the tokens of one CREATE TABLE statementtokens, or -1public static boolean ignoreClausesBeforeQuery(TSourceTokenList tokens, int queryStart)
tokens - the tokens of one CREATE TABLE statementqueryStart - the position returned by queryStart(gudusoft.gsqlparser.TSourceTokenList)