diff --git a/core/src/main/codegen/templates/Parser.jj b/core/src/main/codegen/templates/Parser.jj index 7e53845a52c0..e3f652b2558e 100644 --- a/core/src/main/codegen/templates/Parser.jj +++ b/core/src/main/codegen/templates/Parser.jj @@ -41,18 +41,27 @@ import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.runtime.CalciteContextException; import org.apache.calcite.sql.JoinConditionType; import org.apache.calcite.sql.JoinType; +import org.apache.calcite.sql.SqlAlterQuarkCube; import org.apache.calcite.sql.SqlAlterQuarkDataSource; +import org.apache.calcite.sql.SqlAlterQuarkDimension; +import org.apache.calcite.sql.SqlAlterQuarkMeasure; import org.apache.calcite.sql.SqlAlterQuarkView; import org.apache.calcite.sql.SqlBinaryOperator; import org.apache.calcite.sql.SqlCall; import org.apache.calcite.sql.SqlCharStringLiteral; import org.apache.calcite.sql.SqlCollation; +import org.apache.calcite.sql.SqlCreateQuarkCube; import org.apache.calcite.sql.SqlCreateQuarkDataSource; +import org.apache.calcite.sql.SqlCreateQuarkDimension; +import org.apache.calcite.sql.SqlCreateQuarkMeasure; import org.apache.calcite.sql.SqlCreateQuarkView; import org.apache.calcite.sql.SqlDataTypeSpec; import org.apache.calcite.sql.SqlDateLiteral; import org.apache.calcite.sql.SqlDelete; +import org.apache.calcite.sql.SqlDropQuarkCube; import org.apache.calcite.sql.SqlDropQuarkDataSource; +import org.apache.calcite.sql.SqlDropQuarkDimension; +import org.apache.calcite.sql.SqlDropQuarkMeasure; import org.apache.calcite.sql.SqlDropQuarkView; import org.apache.calcite.sql.SqlDynamicParam; import org.apache.calcite.sql.SqlExplain; @@ -955,6 +964,24 @@ SqlNode SqlStmt() : stmt = SqlAlterQuarkView() | stmt = SqlDropQuarkView() + | + stmt = SqlCreateQuarkCube() + | + stmt = SqlAlterQuarkCube() + | + stmt = SqlDropQuarkCube() + | + stmt = SqlCreateQuarkMeasure() + | + stmt = SqlAlterQuarkMeasure() + | + stmt = SqlDropQuarkMeasure() + | + stmt = SqlCreateQuarkDimension() + | + stmt = SqlAlterQuarkDimension() + | + stmt = SqlDropQuarkDimension() <#-- Add methods to parse additional statements here --> <#list parser.statementParserMethods as method> @@ -1503,6 +1530,272 @@ SqlNode SqlDropQuarkView() : return new SqlDropQuarkView(pos, condition); } } +/** + * Parses an CREATE CUBE statement. + */ +SqlNode SqlCreateQuarkCube() : +{ + SqlNode source; + SqlNodeList columnList = null; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + } + + [ + LOOKAHEAD(2) + columnList = ParenthesizedSimpleIdentifierList() + ] + source = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) + { + return new SqlCreateQuarkCube(pos, source, columnList); + } +} + +/** + * Parses an ALTER CUBE statement. + */ +SqlNode SqlAlterQuarkCube() : +{ + SqlNode condition; + SqlNodeList sourceExpressionList; + SqlNodeList targetColumnList; + SqlIdentifier id; + SqlNode exp; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + targetColumnList = new SqlNodeList(pos); + sourceExpressionList = new SqlNodeList(pos); + } + id = SimpleIdentifier() + { + targetColumnList.add(id); + } + exp = Expression(ExprContext.ACCEPT_SUBQUERY) + { + sourceExpressionList.add(exp); + } + ( + + id = SimpleIdentifier() + { + targetColumnList.add(id); + } + exp = Expression(ExprContext.ACCEPT_SUBQUERY) + { + sourceExpressionList.add(exp); + } + ) * + condition = WhereOpt() + { + return new SqlAlterQuarkCube(pos, targetColumnList, sourceExpressionList, + condition); + } +} + +/** + * Parses a DELETE CUBE statement. + */ +SqlNode SqlDropQuarkCube() : +{ + SqlNode condition; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + } + condition = WhereOpt() + { + return new SqlDropQuarkCube(pos, condition); + } +} + +/** + * Parses an CREATE Dimension statement. + */ +SqlNode SqlCreateQuarkDimension() : +{ + SqlNode source; + SqlNodeList columnList = null; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + } + + [ + LOOKAHEAD(2) + columnList = ParenthesizedSimpleIdentifierList() + ] + source = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) + { + return new SqlCreateQuarkDimension(pos, source, columnList); + } +} + +/** + * Parses an ALTER DIMENSION statement. + */ +SqlNode SqlAlterQuarkDimension() : +{ + SqlNode condition; + SqlNodeList sourceExpressionList; + SqlNodeList targetColumnList; + SqlIdentifier id; + SqlNode exp; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + targetColumnList = new SqlNodeList(pos); + sourceExpressionList = new SqlNodeList(pos); + } + id = SimpleIdentifier() + { + targetColumnList.add(id); + } + exp = Expression(ExprContext.ACCEPT_SUBQUERY) + { + sourceExpressionList.add(exp); + } + ( + + id = SimpleIdentifier() + { + targetColumnList.add(id); + } + exp = Expression(ExprContext.ACCEPT_SUBQUERY) + { + sourceExpressionList.add(exp); + } + ) * + condition = WhereOpt() + { + return new SqlAlterQuarkDimension(pos, targetColumnList, sourceExpressionList, + condition); + } +} + +/** + * Parses a DELETE DIMENSION statement. + */ +SqlNode SqlDropQuarkDimension() : +{ + SqlNode condition; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + } + condition = WhereOpt() + { + return new SqlDropQuarkDimension(pos, condition); + } +} + +/** + * Parses an CREATE MEASURE statement. + */ +SqlNode SqlCreateQuarkMeasure() : +{ + SqlNode source; + SqlNodeList columnList = null; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + } + + [ + LOOKAHEAD(2) + columnList = ParenthesizedSimpleIdentifierList() + ] + source = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) + { + return new SqlCreateQuarkMeasure(pos, source, columnList); + } +} + +/** + * Parses an ALTER MEASURE statement. + */ +SqlNode SqlAlterQuarkMeasure() : +{ + SqlNode condition; + SqlNodeList sourceExpressionList; + SqlNodeList targetColumnList; + SqlIdentifier id; + SqlNode exp; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + targetColumnList = new SqlNodeList(pos); + sourceExpressionList = new SqlNodeList(pos); + } + id = SimpleIdentifier() + { + targetColumnList.add(id); + } + exp = Expression(ExprContext.ACCEPT_SUBQUERY) + { + sourceExpressionList.add(exp); + } + ( + + id = SimpleIdentifier() + { + targetColumnList.add(id); + } + exp = Expression(ExprContext.ACCEPT_SUBQUERY) + { + sourceExpressionList.add(exp); + } + ) * + condition = WhereOpt() + { + return new SqlAlterQuarkMeasure(pos, targetColumnList, sourceExpressionList, + condition); + } +} + +/** + * Parses a DELETE MEASURE statement. + */ +SqlNode SqlDropQuarkMeasure() : +{ + SqlNode condition; + SqlParserPos pos; +} +{ + + { + pos = getPos(); + } + condition = WhereOpt() + { + return new SqlDropQuarkMeasure(pos, condition); + } +} /** * Parses a MERGE statement. diff --git a/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkCube.java b/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkCube.java new file mode 100644 index 000000000000..5a5cf0acd81d --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkCube.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlAlterQuarkCube is a node of a parse tree which represents an ALTER + * metadata for Quark Cube + */ +public class SqlAlterQuarkCube extends SqlAlterQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlAlterQuarkCube(SqlParserPos pos, + SqlNodeList targetColumnList, + SqlNodeList sourceExpressionList, + SqlNode condition) { + super(pos, targetColumnList, sourceExpressionList, condition); + operator = new SqlSpecialOperator("ALTER_CUBE", SqlKind.OTHER_DDL); + operatorString = "ALTER CUBE"; + } +} + +// End SqlAlterQuarkCube.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkDimension.java b/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkDimension.java new file mode 100644 index 000000000000..d185eae1c583 --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkDimension.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlAlterQuarkDimension is a node of a parse tree which represents an ALTER + * metadata for Quark Dimension + */ +public class SqlAlterQuarkDimension extends SqlAlterQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlAlterQuarkDimension(SqlParserPos pos, + SqlNodeList targetColumnList, + SqlNodeList sourceExpressionList, + SqlNode condition) { + super(pos, targetColumnList, sourceExpressionList, condition); + operator = new SqlSpecialOperator("ALTER_DIMENSION", SqlKind.OTHER_DDL); + operatorString = "ALTER DIMENSION"; + } +} + +// End SqlAlterQuarkDimension.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkMeasure.java b/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkMeasure.java new file mode 100644 index 000000000000..9d2cd9a9fc6d --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlAlterQuarkMeasure.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlAlterQuarkMeasure is a node of a parse tree which represents an ALTER + * metadata for Quark Measure + */ +public class SqlAlterQuarkMeasure extends SqlAlterQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlAlterQuarkMeasure(SqlParserPos pos, + SqlNodeList targetColumnList, + SqlNodeList sourceExpressionList, + SqlNode condition) { + super(pos, targetColumnList, sourceExpressionList, condition); + operator = new SqlSpecialOperator("ALTER_MEASURE", SqlKind.OTHER_DDL); + operatorString = "ALTER MEASURE"; + } +} + +// End SqlAlterQuarkMeasure.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkCube.java b/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkCube.java new file mode 100644 index 000000000000..6fbe8e3f7955 --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkCube.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlCreateQuarkCube is a node of a parse tree which represents an INSERT + * statement. + */ +public class SqlCreateQuarkCube extends SqlCreateQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlCreateQuarkCube(SqlParserPos pos, + SqlNode source, + SqlNodeList columnList) { + super(pos, source, columnList); + operator = new SqlSpecialOperator("CREATE_CUBE", SqlKind.OTHER_DDL); + operatorString = "CREATE CUBE"; + } +} + +// End SqlCreateQuarkCube.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkDimension.java b/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkDimension.java new file mode 100644 index 000000000000..20b2a1a30cc7 --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkDimension.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlCreateQuarkDimension is a node of a parse tree which represents an INSERT + * statement. + */ +public class SqlCreateQuarkDimension extends SqlCreateQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlCreateQuarkDimension(SqlParserPos pos, + SqlNode source, + SqlNodeList columnList) { + super(pos, source, columnList); + operator = new SqlSpecialOperator("CREATE_DIMENSION", SqlKind.OTHER_DDL); + operatorString = "CREATE DIMENSION"; + } +} + +// End SqlCreateQuarkDimension.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkMeasure.java b/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkMeasure.java new file mode 100644 index 000000000000..842655cb1857 --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlCreateQuarkMeasure.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlCreateQuarkMeasure is a node of a parse tree which represents an INSERT + * statement. + */ +public class SqlCreateQuarkMeasure extends SqlCreateQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlCreateQuarkMeasure(SqlParserPos pos, + SqlNode source, + SqlNodeList columnList) { + super(pos, source, columnList); + operator = new SqlSpecialOperator("CREATE_MEASURE", SqlKind.OTHER_DDL); + operatorString = "CREATE MEASURE"; + } +} + +// End SqlCreateQuarkMeasure.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkCube.java b/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkCube.java new file mode 100644 index 000000000000..4529444f3c20 --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkCube.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlDropQuarkCube is a node of a parse tree which represents a DROP DDL + * statements for Quark Cube. + */ +public class SqlDropQuarkCube extends SqlDropQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlDropQuarkCube( + SqlParserPos pos, + SqlNode condition) { + super(pos, condition); + operator = new SqlSpecialOperator("DROP_CUBE", SqlKind.OTHER_DDL); + operatorString = "DROP CUBE"; + } +} + +// End SqlDropQuarkCube.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkDimension.java b/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkDimension.java new file mode 100644 index 000000000000..154ba6914aae --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkDimension.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlDropQuarkDimension is a node of a parse tree which represents a DROP DDL + * statements for Quark Dimension. + */ +public class SqlDropQuarkDimension extends SqlDropQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlDropQuarkDimension( + SqlParserPos pos, + SqlNode condition) { + super(pos, condition); + operator = new SqlSpecialOperator("DROP_DIMENSION", SqlKind.OTHER_DDL); + operatorString = "DROP DIMENSION"; + } +} + +// End SqlDropQuarkDimension.java diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkMeasure.java b/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkMeasure.java new file mode 100644 index 000000000000..9fad74b91802 --- /dev/null +++ b/core/src/main/java/org/apache/calcite/sql/SqlDropQuarkMeasure.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.calcite.sql; + +import org.apache.calcite.sql.parser.SqlParserPos; + +/** + * A SqlDropQuarkMeasure is a node of a parse tree which represents a DROP DDL + * statements for Quark Measure. + */ +public class SqlDropQuarkMeasure extends SqlDropQuark { + //~ Constructors ----------------------------------------------------------- + + public SqlDropQuarkMeasure( + SqlParserPos pos, + SqlNode condition) { + super(pos, condition); + operator = new SqlSpecialOperator("DROP_MEASURE", SqlKind.OTHER_DDL); + operatorString = "DROP MEASURE"; + } +} + +// End SqlDropQuarkMeasure.java