Java Code Examples for org.apache.calcite.sql.SqlSelect#getWhere()
The following examples show how to use
org.apache.calcite.sql.SqlSelect#getWhere() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlValidatorImpl.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
protected void validateWhereClause(SqlSelect select) { // validate WHERE clause final SqlNode where = select.getWhere(); if (where == null) { return; } final SqlValidatorScope whereScope = getWhereScope(select); final SqlNode expandedWhere = expand(where, whereScope); select.setWhere(expandedWhere); validateWhereOrOn(whereScope, expandedWhere, "WHERE"); }
Example 2
Source File: SqlValidatorImpl.java From flink with Apache License 2.0 | 5 votes |
protected void validateWhereClause(SqlSelect select) { // validate WHERE clause final SqlNode where = select.getWhere(); if (where == null) { return; } final SqlValidatorScope whereScope = getWhereScope(select); final SqlNode expandedWhere = expand(where, whereScope); select.setWhere(expandedWhere); validateWhereOrOn(whereScope, expandedWhere, "WHERE"); }
Example 3
Source File: MysqlSideFunction.java From alchemy with Apache License 2.0 | 5 votes |
private String modifySql(SideTable sideTable) throws SqlParseException { SqlParser.Config config = SqlParser.configBuilder().setLex(Lex.MYSQL).build(); SqlParser sqlParser = SqlParser.create(sideTable.getSql(), config); SqlNode sqlNode = sqlParser.parseStmt(); if (SqlKind.SELECT != sqlNode.getKind()) { throw new UnsupportedOperationException( "MysqlAsyncReqRow only support query sql, sql:" + sideTable.getSql()); } SqlSelect sqlSelect = (SqlSelect)sqlNode; SqlNode whereNode = sqlSelect.getWhere(); SqlBinaryOperator and = new SqlBinaryOperator("AND", SqlKind.AND, 24, true, ReturnTypes.BOOLEAN_NULLABLE_OPTIMIZED, InferTypes.BOOLEAN, OperandTypes.BOOLEAN_BOOLEAN); List<SqlBasicCall> conditionNodes = createConditionNodes(sideTable.getConditions(), sideTable.getSideAlias()); List<SqlNode> nodes = new ArrayList<>(); nodes.addAll(conditionNodes); if (whereNode != null) { nodes.add(whereNode); } else { SqlBinaryOperator equal = new SqlBinaryOperator("=", SqlKind.EQUALS, 30, true, ReturnTypes.BOOLEAN_NULLABLE, InferTypes.FIRST_KNOWN, OperandTypes.COMPARABLE_UNORDERED_COMPARABLE_UNORDERED); SqlBasicCall andEqual = new SqlBasicCall(equal, SideParser.createEqualNodes(SqlKind.AND), new SqlParserPos(0, 0)); nodes.add(andEqual); } SqlBasicCall sqlBasicCall = new SqlBasicCall(and, nodes.toArray(new SqlNode[nodes.size()]), new SqlParserPos(0, 0)); sqlSelect.setWhere(sqlBasicCall); return sqlSelect.toString(); }
Example 4
Source File: SqlParseUtil.java From alchemy with Apache License 2.0 | 5 votes |
private static void parseSource(SqlSelect sqlSelect, List<String> sources, List<String> udfs) throws SqlParseException { SqlNodeList selectList = sqlSelect.getSelectList(); SqlNode from = sqlSelect.getFrom(); SqlNode where = sqlSelect.getWhere(); SqlNode having = sqlSelect.getHaving(); parseSelectList(selectList, sources, udfs); parseFrom(from, sources, udfs); parseFunction(where, udfs); parseFunction(having, udfs); }
Example 5
Source File: RuleParser.java From streamline with Apache License 2.0 | 5 votes |
private Condition parseCondition(SqlSelect sqlSelect) { Condition condition = null; SqlNode where = sqlSelect.getWhere(); if (where != null) { ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs); condition = new Condition(where.accept(exprGenerator)); referredUdfs.addAll(exprGenerator.getReferredUdfs()); } LOG.debug("Condition {}", condition); return condition; }
Example 6
Source File: QuerySemantics.java From dremio-oss with Apache License 2.0 | 4 votes |
private static VirtualDatasetState.Builder extractSelect(String sql, SqlNode node, final RelDataType relDataType) { SqlSelect select = (SqlSelect)node; // From table final SqlNode fromNode = select.getFrom(); if (fromNode == null) { return fallback("without FROM clause", node, sql); } final FromNode from = extractFrom(fromNode); // Selected columns final List<Column> columns = extractColumns(relDataType, select, from); final SqlNode where = select.getWhere(); if (where != null) { return fallback("where is not supported yet", where, sql); } final SqlNodeList groupBy = select.getGroup(); if (groupBy != null) { return fallback("group by is not supported yet", groupBy, sql); } final SqlNode having = select.getHaving(); if (having != null) { return fallback("having is not supported yet", having, sql); } final SqlNodeList windowDecls = select.getWindowList(); if (windowDecls != null && !windowDecls.getList().isEmpty()) { return fallback("window is not supported yet", windowDecls, sql); } final List<Order> orders = extractOrders(select.getOrderList(), from); final SqlNode offset = select.getOffset(); if (offset != null) { return fallback("offset is not supported yet", offset, sql); } final SqlNode fetch = select.getFetch(); if (fetch != null) { return fallback("fetch is not supported yet", fetch, sql); } From.Builder fromTable = From.newBuilder() .setType(FromType.TABLE) .setValue(from.getTableToString()); if (from.alias != null) { fromTable.setAlias(from.getAliasToString()); } final VirtualDatasetState.Builder state = VirtualDatasetState.newBuilder().setFrom(fromTable); if (columns != null) { state.addAllColumns(columns); } if (orders != null) { state.addAllOrders(orders); } return state; }