use of org.apache.ignite.internal.sql.engine.schema.TableDescriptor in project ignite-3 by apache.
the class IgniteSqlValidator method inferColumnList.
private SqlNodeList inferColumnList(SqlInsert call) {
final SqlValidatorTable table = table(validatedNamespace(call, unknownType));
if (table == null) {
return null;
}
final TableDescriptor desc = table.unwrap(TableDescriptor.class);
if (desc == null) {
return null;
}
final SqlNodeList columnList = new SqlNodeList(SqlParserPos.ZERO);
for (RelDataTypeField field : desc.insertRowType(typeFactory()).getFieldList()) {
columnList.add(new SqlIdentifier(field.getName(), SqlParserPos.ZERO));
}
return columnList;
}
use of org.apache.ignite.internal.sql.engine.schema.TableDescriptor in project ignite-3 by apache.
the class IgniteSqlValidator method validateUpdateFields.
private void validateUpdateFields(SqlUpdate call) {
if (call.getTargetColumnList() == null) {
return;
}
final SqlValidatorNamespace ns = validatedNamespace(call, unknownType);
final SqlValidatorTable table = table(ns);
if (table == null) {
return;
}
final TableDescriptor desc = table.unwrap(TableDescriptor.class);
if (desc == null) {
return;
}
final RelDataType baseType = table.getRowType();
final RelOptTable relOptTable = relOptTable(ns);
for (SqlNode node : call.getTargetColumnList()) {
SqlIdentifier id = (SqlIdentifier) node;
RelDataTypeField target = SqlValidatorUtil.getTargetField(baseType, typeFactory(), id, getCatalogReader(), relOptTable);
if (target == null) {
throw newValidationError(id, RESOURCE.unknownTargetColumn(id.toString()));
}
if (!desc.isUpdateAllowed(relOptTable, target.getIndex())) {
throw newValidationError(id, IgniteResource.INSTANCE.cannotUpdateField(id.toString()));
}
}
}
Aggregations