NIFI-4051: Ensure that we use the appropriate Lexical syntax for SQL query validation as we do when running

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #2054.
This commit is contained in:
Mark Payne 2017-08-03 16:56:10 -04:00 committed by Pierre Villard
parent 40cde0466a
commit 969bbe654c
1 changed files with 7 additions and 1 deletions

View File

@ -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()