Java Code Examples for org.apache.calcite.sql.SqlIdentifier#toString()
The following examples show how to use
org.apache.calcite.sql.SqlIdentifier#toString() .
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: AccelCreateReflectionHandler.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public List<SimpleCommandResult> toResult(String sql, SqlNode sqlNode) throws Exception { final SqlCreateReflection addLayout = SqlNodeUtil.unwrap(sqlNode, SqlCreateReflection.class); final TableWithPath table = SchemaUtilities.verify(catalog, addLayout.getTblName()); SqlIdentifier identifier = addLayout.getName(); String name; if(identifier != null) { name = identifier.toString(); } else { name = "Unnamed-" + ThreadLocalRandom.current().nextLong(); } final LayoutDefinition layout = new LayoutDefinition(name, addLayout.isRaw() ? LayoutDefinition.Type.RAW : LayoutDefinition.Type.AGGREGATE, table.qualifyColumns(addLayout.getDisplayList()), qualifyColumnsWithGranularity(table.getTable(), addLayout.getDimensionList()), qualifyColumnsWithMeasures(table.getTable(), addLayout.getMeasureList()), table.qualifyColumns(addLayout.getSortList()), table.qualifyColumns(addLayout.getDistributionList()), table.qualifyColumns(addLayout.getPartitionList()), addLayout.getPartitionDistributionStrategy() ); accel.addLayout(table.getPath(), layout, reflectionContext); return Collections.singletonList(SimpleCommandResult.successful("Layout added.")); }
Example 2
Source File: MergeTableLikeUtil.java From flink with Apache License 2.0 | 6 votes |
private void appendDerivedWatermarks( Map<FeatureOption, MergingStrategy> mergingStrategies, List<SqlWatermark> derivedWatermarkSpecs) { for (SqlWatermark derivedWatermarkSpec : derivedWatermarkSpecs) { SqlIdentifier eventTimeColumnName = derivedWatermarkSpec.getEventTimeColumnName(); HashMap<String, RelDataType> nameToTypeMap = new LinkedHashMap<>(physicalFieldNamesToTypes); nameToTypeMap.putAll(computedFieldNamesToTypes); verifyRowtimeAttribute(mergingStrategies, eventTimeColumnName, nameToTypeMap); String rowtimeAttribute = eventTimeColumnName.toString(); SqlNode expression = derivedWatermarkSpec.getWatermarkStrategy(); // this will validate and expand function identifiers. SqlNode validated = sqlValidator.validateParameterizedExpression(expression, nameToTypeMap); RelDataType validatedType = sqlValidator.getValidatedNodeType(validated); DataType exprDataType = fromLogicalToDataType(toLogicalType(validatedType)); watermarkSpecs.put(rowtimeAttribute, new WatermarkSpec( rowtimeAttribute, escapeExpressions.apply(validated), exprDataType)); } }
Example 3
Source File: SqlNodeConverter.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public SqlNode visit(SqlIdentifier id) { String maybeParam = id.toString(); int idx = ParamNodeParser.parseParamIdx(maybeParam); if (idx >= 0 && operands.containsKey(idx)) { SqlNode sqlNode = operands.get(idx); if (sqlNode instanceof SqlIdentifier) { return sqlNode; } else { return sqlNode.accept(SqlNodeConverter.this); } } return id; }
Example 4
Source File: SqlNodeConverter.java From kylin with Apache License 2.0 | 5 votes |
@Override public SqlNode visit(SqlIdentifier id) { String maybeParam = id.toString(); int idx = ParamNodeParser.parseParamIdx(maybeParam); if (idx >= 0 && operands.containsKey(idx)) { SqlNode sqlNode = operands.get(idx); if (sqlNode instanceof SqlIdentifier) { return sqlNode; } else { return sqlNode.accept(SqlNodeConverter.this); } } return id; }
Example 5
Source File: MergeTableLikeUtil.java From flink with Apache License 2.0 | 4 votes |
private void verifyRowtimeAttribute( Map<FeatureOption, MergingStrategy> mergingStrategies, SqlIdentifier eventTimeColumnName, Map<String, RelDataType> allFieldsTypes) { String fullRowtimeExpression = eventTimeColumnName.toString(); boolean specAlreadyExists = watermarkSpecs.containsKey(fullRowtimeExpression); if (specAlreadyExists && mergingStrategies.get(FeatureOption.WATERMARKS) != MergingStrategy.OVERWRITING) { throw new ValidationException(String.format( "There already exists a watermark spec for column '%s' in the base table. You " + "might want to specify EXCLUDING WATERMARKS or OVERWRITING WATERMARKS.", fullRowtimeExpression)); } List<String> components = eventTimeColumnName.names; if (!allFieldsTypes.containsKey(components.get(0))) { throw new ValidationException( String.format( "The rowtime attribute field '%s' is not defined in the table schema, at %s\n" + "Available fields: [%s]", fullRowtimeExpression, eventTimeColumnName.getParserPosition(), allFieldsTypes.keySet().stream().collect(Collectors.joining("', '", "'", "'")) )); } if (components.size() > 1) { RelDataType componentType = allFieldsTypes.get(components.get(0)); for (int i = 1; i < components.size(); i++) { RelDataTypeField field = componentType.getField(components.get(i), true, false); if (field == null) { throw new ValidationException( String.format( "The rowtime attribute field '%s' is not defined in the table schema, at %s\n" + "Nested field '%s' was not found in a composite type: %s.", fullRowtimeExpression, eventTimeColumnName.getComponent(i).getParserPosition(), components.get(i), FlinkTypeFactory.toLogicalType(allFieldsTypes.get(components.get(0)))) ); } componentType = field.getType(); } } }