lowka commented on code in PR #1651:
URL: https://github.com/apache/ignite-3/pull/1651#discussion_r1102275858
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlValidator.java:
##########
@@ -158,6 +163,51 @@ public void validateInsert(SqlInsert insert) {
}
super.validateInsert(insert);
+
+ checkFixedLenCols(insert);
+ }
+
+ private void checkFixedLenCols(SqlInsert insert) {
+ RelDataType srcRowType = getNamespace(insert.getSource()).getRowType();
+
+ SqlValidatorNamespace targetNamespace = getNamespace(insert);
+
+ RelOptTable relOptTable = SqlValidatorUtil.getRelOptTable(
+ targetNamespace,
getCatalogReader().unwrap(Prepare.CatalogReader.class), null, null);
+
+ SqlValidatorTable table = relOptTable == null
+ ? getTable(targetNamespace)
+ : relOptTable.unwrapOrThrow(SqlValidatorTable.class);
+
+ RelDataType destRowType = createTargetRowType(table,
insert.getTargetColumnList(), false);
+
+ List<RelDataTypeField> srcFields = srcRowType.getFieldList();
+
+ List<RelDataTypeField> dstFields = destRowType.getFieldList();
+
+ // will be validated later
+ if (srcFields.size() != dstFields.size()) {
+ return;
+ }
+
+ for (int i = 0; i < srcFields.size(); ++i) {
+ RelDataType srcType = srcFields.get(i).getValue();
+ RelDataType dstType = dstFields.get(i).getValue();
+
+ if (SqlTypeUtil.isString(dstType) && srcType.getPrecision() !=
RelDataType.PRECISION_NOT_SPECIFIED) {
+ String val = srcFields.get(i).getKey();
+ String src = brace.matcher(val).replaceAll("");
+ // it`s correct here to cut probably more.
+ src = src.stripTrailing();
Review Comment:
We can only replace "'" at the beginning and at the end of a literal.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]