From 969bbe654c572f4156c71f1d05045219d433eab6 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Thu, 3 Aug 2017 16:56:10 -0400 Subject: [PATCH] NIFI-4051: Ensure that we use the appropriate Lexical syntax for SQL query validation as we do when running Signed-off-by: Pierre Villard This closes #2054. --- .../org/apache/nifi/processors/standard/QueryRecord.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java index f0ed52da3b..f1d28d155a 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java @@ -46,6 +46,7 @@ import org.apache.calcite.config.Lex; import org.apache.calcite.jdbc.CalciteConnection; import org.apache.calcite.schema.SchemaPlus; import org.apache.calcite.sql.parser.SqlParser; +import org.apache.calcite.sql.parser.SqlParser.Config; import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.behavior.DynamicRelationship; import org.apache.nifi.annotation.behavior.EventDriven; @@ -546,7 +547,12 @@ public class QueryRecord extends AbstractProcessor { } final String substituted = context.newPropertyValue(input).evaluateAttributeExpressions().getValue(); - final SqlParser parser = SqlParser.create(substituted); + + final Config config = SqlParser.configBuilder() + .setLex(Lex.MYSQL_ANSI) + .build(); + + final SqlParser parser = SqlParser.create(substituted, config); try { parser.parseStmt(); return new ValidationResult.Builder()