public String functionName() { return functionName.toString(); }
public String tableName() { return tblName.toString(); }
@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; }
@Override public boolean isSqlIdentifierEqual(SqlIdentifier querySqlIdentifier, SqlIdentifier exprSqlIdentifier) { int parsedIdx = ParamNodeParser.parseParamIdx(exprSqlIdentifier.toString()); if (parsedIdx >= 0) { SqlNode matchedBefore = matchedNodesMap.get(parsedIdx); if (matchedBefore != null) { return ExpressionComparator.isNodeEqual(querySqlIdentifier, matchedBefore, this); } else { matchedNodesMap.put(parsedIdx, querySqlIdentifier); return true; } } else { return querySqlIdentifier.equalsDeep(exprSqlIdentifier, Litmus.IGNORE); } }
private RelDataType validateUsingCol(SqlIdentifier id, SqlNode leftOrRight) { if (id.names.size() == 1) { String name = id.names.get(0); final SqlValidatorNamespace namespace = getNamespace(leftOrRight); final RelDataType rowType = namespace.getRowType(); final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); final RelDataTypeField field = nameMatcher.field(rowType, name); if (field != null) { if (nameMatcher.frequency(rowType.getFieldNames(), name) > 1) { throw newValidationError(id, RESOURCE.columnInUsingNotUnique(id.toString())); } return field.getType(); } } throw newValidationError(id, RESOURCE.columnNotFound(id.toString())); }
protected SqlWindow getWindowByName( SqlIdentifier id, SqlValidatorScope scope) { SqlWindow window = null; if (id.isSimple()) { final String name = id.getSimple(); window = scope.lookupWindow(name); } if (window == null) { throw newValidationError(id, RESOURCE.windowNotFound(id.toString())); } return window; }
if (targetField == null) { throw newValidationError(id, RESOURCE.unknownTargetColumn(id.toString()));
public void validateSequenceValue(SqlValidatorScope scope, SqlIdentifier id) { // Resolve identifier as a table. final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolveTable(id.names, catalogReader.nameMatcher(), SqlValidatorScope.Path.EMPTY, resolved); if (resolved.count() != 1) { throw newValidationError(id, RESOURCE.tableNameNotFound(id.toString())); } // We've found a table. But is it a sequence? final SqlValidatorNamespace ns = resolved.only().namespace; if (ns instanceof TableNamespace) { final Table table = ns.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case SEQUENCE: case TEMPORARY_SEQUENCE: return; } } throw newValidationError(id, RESOURCE.notASequence(id.toString())); }
final SqlIdentifier last = id.getComponent(i - 1, i); throw newValidationError(last, RESOURCE.unknownIdentifier(last.toString()));
RESOURCE.unknownIdentifier(prefixId.toString()));
RESOURCE.unknownDatatypeName(sqlIdentifier.toString()));
SqlDataTypeSpec findTargetSqlDataTypeSpec(SqlDataTypeSpec typeSpec) { if (sourceDS == null || targetDS == null || typeSpec == null) return null; List<TypeDef> validTypeDefs = sourceDS.getTypeDefsByName(typeSpec.getTypeName().toString()); if (validTypeDefs != null) { for (TypeDef typeDef : validTypeDefs) { if (typeDef.getMaxPrecision() >= typeSpec.getPrecision()) { TypeDef targetType = targetDS.getTypeDef(typeDef.getId()); return new SqlDataTypeSpec(new SqlIdentifier(targetType.getName(), typeSpec.getParserPosition()), targetType.getDefaultPrecision() >= 0 ? targetType.getDefaultPrecision() : typeSpec.getPrecision(), targetType.getDefaultScale() >= 0 ? targetType.getDefaultScale() : typeSpec.getScale(), typeSpec.getCharSetName(), typeSpec.getTimeZone(), typeSpec.getParserPosition()); } } } return null; }
private void extract(SqlSetOption node) { Object value = unwrapConstant(node.getValue()); String property = node.getName().toString(); Preconditions.checkArgument(!"SYSTEM".equals(node.getScope()), "cannot set properties at the system level"); conf.setProperty(property, value); }
/** * Get the schema name. A schema identifier can contain more than one level of schema. * Ex: "dfs.home" identifier contains two levels "dfs" and "home". * @return schemas combined with "." */ public String getSchema() { return schema.toString(); } }
@Override public boolean apply(SqlIdentifier input) { return !RESERVED_PARENT_NAMES.contains(input.toString()); } }
protected void generateTypeString(StringBuilder sb, boolean withDetail) { // TODO jvs 10-Feb-2005: proper quoting; dump attributes withDetail? sb.append("ObjectSqlType("); sb.append(sqlIdentifier.toString()); sb.append(")"); } }
protected void generateTypeString(StringBuilder sb, boolean withDetail) { // TODO jvs 10-Feb-2005: proper quoting; dump attributes withDetail? sb.append("ObjectSqlType("); sb.append(sqlIdentifier.toString()); sb.append(")"); } }
@Override public List<SimpleCommandResult> toResult(String sql, SqlNode sqlNode) throws Exception { final SqlDropReflection dropReflection = SqlNodeUtil.unwrap(sqlNode, SqlDropReflection.class); TableWithPath table = SchemaUtilities.verify(catalog, dropReflection.getTblName()); accel.dropLayout(table.getPath(), dropReflection.getLayoutId().toString()); return Collections.singletonList(SimpleCommandResult.successful("Reflection dropped.")); }
public void validateAncestors(String sql, String... ancestors) { QueryMetadata metadata = QueryParser.extract(new SqlQuery(sql, null, DEFAULT_USERNAME), l(SabotContext.class)); List<SqlIdentifier> actualAncestors = metadata.getAncestors().get(); String message = "expected: " + Arrays.toString(ancestors) + " actual: " + actualAncestors; Assert.assertEquals(message, ancestors.length, actualAncestors.size()); for (int i = 0; i < ancestors.length; i++) { String expectedAncestor = ancestors[i]; String actualAncestor = actualAncestors.get(i).toString(); Assert.assertEquals(message, expectedAncestor, actualAncestor); } }