THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// Add SqlDescribeCatalog & DescribeCatalogOperation // Add SqlDescribeDatabase & DescribeDatabaseOperation // Add SqlDescribeFunction & DescribeFunctionOperation // Changed SqlNodes & Operations // SqlShowCatalogs public class SqlShowCatalogs extends SqlCall { public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("SHOW CATALOGS", SqlKind.OTHER); //protected Addfinal LIKESqlLikeType supportlikeType; protected final boolean notLike; protected final SqlCharStringLiteral likeLiteral; public SqlShowCatalogs(SqlParserPos pos) { super(pos); this.likeType = null; this.notLike = false; this.likeLiteral = null; } public SqlShowCatalogs( SqlParserPos pos, String likeType, boolean notLike, SqlCharStringLiteral likeLiteral) { super(pos); this.notLike = notLike; if (likeType != null) { this.likeLiterallikeType = likeLiteralSqlLikeType.of(likeType); } public boolean isNotLike() { this.likeLiteral = requireNonNull(likeLiteral, "Like pattern must not returnbe notLikenull"); } public} Stringelse getLikeSqlPattern() { return Objects.isNull(this.likeLiteral)likeType ?= null : likeLiteral.getValueAs(String.class); } public boolean isWithLike() { this.likeLiteral = null; return Objects.nonNull(likeLiteral); } } this.notLike = notLike; @Override} public SqlOperatorSqlLikeType getOperatorgetLikeType() { return OPERATORlikeType; } @Override public List<SqlNode>boolean getOperandListisLike() { return Collections.emptyList()likeType == SqlLikeType.LIKE; } public boolean isILike() @Override{ public void unparse(SqlWriter writer,return intlikeType leftPrec, int rightPrec) { == SqlLikeType.ILIKE; } public boolean writer.keyword("SHOW CATALOGS");isWithLike() { ifreturn (isWithLikeisLike() || isILike()) {; } public boolean if (isNotLike()) { return notLike; } writer.keyword(String.format("NOT LIKE '%s'", getLikeSqlPattern()))public String getLikeSqlPattern() { return Objects.isNull(likeLiteral) ? null : likeLiteral.getValueAs(String.class); } @Override } elsepublic SqlOperator getOperator() { return OPERATOR; } writer.keyword(String.format("LIKE '%s'", getLikeSqlPattern())); @Override public List<SqlNode> getOperandList() { } return Collections.emptyList(); } }@Override } // ShowCatalogsOperation public class ShowCatalogsOperationpublic implementsvoid ShowOperation { private final boolean withLike;unparse(SqlWriter writer, int leftPrec, int rightPrec) { private final boolean notLike; writer.keyword("SHOW CATALOGS"); private final String likePattern; if public ShowCatalogsOperation(boolean notLike, String likePattern(isWithLike()) { this.withLike = likePattern != null; if (isNotLike()) { this.notLike = notLike; this.likePattern = likePattern; writer.keyword(String.format("NOT %s '%s'", likeType.name(), getLikeSqlPattern())); } public boolean} isWithLike()else { return withLike; } public boolean isNotLike() {writer.keyword(String.format("%s '%s'", likeType.name(), getLikeSqlPattern())); return notLike; } public String getLikePattern() {} } } // ShowCatalogsOperation public class returnShowCatalogsOperation likePattern; implements ShowOperation }{ @Override private final OperationLikeType likeType; public String asSummaryString() { private final boolean notLike; private StringBuilderfinal builder = new StringBuilder().append("SHOW CATALOGS"); String likePattern; /** Use when there if (withLike) {is no sub-clause. */ if (notLikepublic ShowCatalogsOperation() { this.likeType = null; builder.append(String.format(" %s LIKE %s", "NOT", likePattern))this.notLike = false; this.likePattern = null; } else {} /** Use when there is like. */ public builder.appendShowCatalogsOperation(String.format(" LIKE %s", likePattern)); likeType, boolean notLike, String likePattern) { this.likeType = OperationLikeType.of(checkNotNull(likeType, "Like } type must not be null")); } this.likePattern = checkNotNull(likePattern, "Like return builder.toString(pattern must not be null"); } } // SqlShowDatabases public class SqlShowDatabases extends SqlCall { this.notLike = notLike; } public staticboolean final SqlSpecialOperator OPERATOR =isLike() { return likeType == OperationLikeType.LIKE; new SqlSpecialOperator("SHOW DATABASES", SqlKind.OTHER); } //public Add IN/FROM and LIKE support protected final SqlIdentifier catalogName; boolean isIlike() { protectedreturn finallikeType String preposition== OperationLikeType.ILIKE; protected final boolean notLike; protected final SqlCharStringLiteral likeLiteral; } public SqlShowDatabases(SqlParserPos posboolean isWithLike() { return superisLike(pos); || isIlike(); } this.catalogName = null; public boolean isNotLike() { this.preposition = nullreturn notLike; } this.notLike = false;public String getLikePattern() { this.likeLiteral = nullreturn likePattern; } public SqlShowDatabases(@Override public String asSummaryString() { SqlParserPos pos, StringBuilder builder = new StringBuilder().append("SHOW CATALOGS"); SqlIdentifier catalogName, if (isWithLike()) { String preposition, if (notLike) { boolean notLike, builder.append(String.format(" NOT %s SqlCharStringLiteral likeLiteral) {%s", likeType.name(), likePattern)); super(pos); } else { this.preposition = preposition; this.catalogName = builder.append(String.format(" %s %s", likeType.name(), likePattern)); preposition != null} } return builder.toString(); } } // SqlShowDatabases public ? requireNonNull(catalogName, "Catalog name must not be null.") class SqlShowDatabases extends SqlCall { public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("SHOW DATABASES", SqlKind.OTHER); : null; protected final String preposition; protected this.notLikefinal =SqlIdentifier notLikecatalogName; protected final SqlLikeType likeType; this.likeLiteral = likeLiteral; protected final boolean }notLike; publicprotected SqlIdentifierfinal getCatalogName() {SqlCharStringLiteral likeLiteral; public SqlShowDatabases(SqlParserPos return catalogName;pos) { } public String catalogNamesuper(pos) {; return catalogName !this.preposition = null ? catalogName.getSimple() : null; } publicthis.catalogName String getPreposition() { = null; this.likeType return= prepositionnull; } publicthis.notLike boolean isWithLike() {= false; return Objectsthis.nonNull(likeLiteral)likeLiteral = null; } public boolean isNotLike() {SqlShowDatabases( return notLike; SqlParserPos }pos, public SqlCharStringLiteral getLikeLiteral() { String preposition, return likeLiteral; } publicSqlIdentifier String getLikeSqlPattern() { catalogName, return Objects.isNull(this.likeLiteral) ? null : likeLiteral.getValueAs(String.class); String likeType, } @Override boolean notLike, public SqlOperator getOperator() { SqlCharStringLiteral returnlikeLiteral) OPERATOR;{ } @Overridesuper(pos); public List<SqlNode> getOperandList() { this.preposition = preposition; return Objects.isNull( this.catalogName) = ? Collections.emptyList()preposition != null : Collections.singletonList(catalogName); } @Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {? requireNonNull(catalogName, "Catalog name must not be null.") if (this.preposition == null) { writer.keyword("SHOW DATABASES"): null; } else if (catalogNamelikeType != null) { writer.keyword("SHOW DATABASES " + this.prepositionthis.likeType = SqlLikeType.of(likeType); catalogName.unparse(writer, leftPrec, rightPrec); }this.likeLiteral = requireNonNull(likeLiteral, "Like pattern must not be null"); if (isWithLike())} else { if (isNotLike()) {this.likeType = null; this.likeLiteral = null; writer.keyword(String.format("NOT LIKE '%s'", getLikeSqlPattern())); } this.notLike = notLike; } else public String getPreposition() { return preposition; } writer.keyword(String.format("LIKE '%s'", getLikeSqlPattern())) public SqlIdentifier getCatalogName() { return catalogName; } public String catalogName() { return catalogName != null ? catalogName.getSimple() : null; } public SqlLikeType getLikeType() { return likeType; } public boolean isLike() { return likeType == SqlLikeType.LIKE; } public boolean isILike() { return likeType == SqlLikeType.ILIKE; } public boolean isNotLike() { return notLike; } public boolean isWithLike() { return isLike() || isILike(); } public SqlCharStringLiteral getLikeLiteral() { return likeLiteral; } public String getLikeSqlPattern() { return Objects.isNull(likeLiteral) ? null : likeLiteral.getValueAs(String.class); } @Override public SqlOperator getOperator() { return OPERATOR; } @Override public List<SqlNode> getOperandList() { return Objects.isNull(this.catalogName) ? Collections.emptyList() : Collections.singletonList(catalogName); } @Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { if (this.preposition == null) { writer.keyword("SHOW DATABASES"); } else if (catalogName != null) { writer.keyword("SHOW DATABASES " + this.preposition); catalogName.unparse(writer, leftPrec, rightPrec); } if (isWithLike()) { if (isNotLike()) { writer.keyword(String.format("NOT %s '%s'", likeType.name(), getLikeSqlPattern())); } else { writer.keyword(String.format("%s '%s'", likeType.name(), getLikeSqlPattern())); } } } // ShowDatabasesOperation public class ShowDatabasesOperation implements ShowOperation { private final String preposition; private final String catalogName; private final boolean withLike; private final boolean notLike; private final String likePattern; public ShowDatabasesOperation() { this.preposition = null; this.catalogName = null; this.withLike = false; this.notLike = false; this.likePattern = null; } public ShowDatabasesOperation(boolean notLike, String likePattern) { this.preposition = null; this.catalogName = null; this.withLike = likePattern != null; this.notLike = notLike; this.likePattern = likePattern; } public ShowDatabasesOperation( String preposition, String catalogName, boolean notLike, String likePattern) { this.preposition = checkNotNull(preposition, "Preposition must not be null"); this.catalogName = checkNotNull(catalogName, "Catalog name must not be null"); this.withLike = likePattern != null; this.notLike = notLike; this.likePattern = likePattern; } public String getPreposition() { return preposition; } public String getCatalogName() { return catalogName; } public boolean isWithLike() { return withLike; } public boolean isNotLike() { return notLike; } public String getLikePattern() { return likePattern; } @Override public String asSummaryString() { StringBuilder builder = new StringBuilder().append("SHOW DATABASES"); if (preposition != null) { builder.append(String.format(" %s %s", preposition, catalogName)); } if (withLike) { if (notLike) { builder.append(String.format(" %s LIKE %s", "NOT", likePattern)); } else { builder.append(String.format(" LIKE %s", likePattern)); } } return builder.toString(); } } public class ShowDatabasesOperation implements ShowOperation { private final String preposition; private final String catalogName; private final OperationLikeType likeType; private final boolean notLike; private final String likePattern; /** Use when there is no sub-clause. */ public ShowDatabasesOperation() { this.preposition = null; this.catalogName = null; this.likeType = null; this.notLike = false; this.likePattern = null; } /** Use when there is only like. */ public ShowDatabasesOperation(String likeType, boolean notLike, String likePattern) { this.preposition = null; this.catalogName = null; } this.likeType } } } // ShowDatabasesOperation public class ShowDatabasesOperation implements ShowOperation { private final String preposition; private final String catalogName; private final boolean withLike; private final boolean notLike; private final String likePattern; = OperationLikeType.of(checkNotNull(likeType, "Like type must not be null")); this.likePattern = checkNotNull(likePattern, "Like pattern must not be null"); this.notLike = notLike; } /** Use when there is preposition and like. */ public ShowDatabasesOperation() { this.preposition = null; String preposition, this.catalogName = null; String catalogName, this.withLike = false; this.notLike =String false;likeType, this.likePattern = null; boolean notLike, } public ShowDatabasesOperation(boolean notLike, String likePattern) { this.preposition = checkNotNull(preposition, "Preposition must not be null"); this.catalogName = checkNotNull(catalogName, "Catalog name must not be null"); this.withLike = likePatternif (likeType != null;) { this.notLikelikeType = notLikeOperationLikeType.of(likeType); this.likePattern = checkNotNull(likePattern, "Like pattern must not be null"); } } publicelse ShowDatabasesOperation({ String preposition, String catalogName, boolean notLike, String likePattern) { this.likeType = null; this.prepositionlikePattern = checkNotNull(preposition, "Preposition must not be null"); null; } this.catalogNamenotLike = checkNotNull(catalogName, "Catalog name must not be null"); notLike; } public String getPreposition() { this.withLike = likePattern !=return nullpreposition; } public this.notLike = notLike;String getCatalogName() { this.likePattern = likePatternreturn catalogName; } public Stringboolean getPrepositionisLike() { return preposition likeType == OperationLikeType.LIKE; } public Stringboolean getCatalogNameisIlike() { return catalogNamelikeType == OperationLikeType.ILIKE; } public boolean isWithLike() { return withLike isLike() || isIlike(); } public boolean isNotLike() { return notLike; } public String getLikePattern() { return likePattern; } @Override public String asSummaryString() { StringBuilder builder = new StringBuilder().append("SHOW DATABASES"); if (preposition != null) { builder.append(String.format(" %s %s", preposition, catalogName)); } if (withLikeisWithLike()) { if (notLike) { builder.append(String.format(" NOT %s LIKE %s", "NOT"likeType.name(), likePattern)); } else { builder.append(String.format(" LIKE%s %s", likeType.name(), likePattern)); } } return builder.toString(); } } // omit here. basically same as ShowCatalogs/ShowDatabases above. // SqlShowFunctions & ShowFunctionsOperation // SqlShowViews & ShowViewsOperation // SqlShowModules & ShowModulesOperation // SqlShowJars & ShowJarsOperation // SqlShowJobs & ShowJobsOperation |
...