[
https://issues.apache.org/jira/browse/FLINK-3631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15201221#comment-15201221
]
ramkrishna.s.vasudevan commented on FLINK-3631:
-----------------------------------------------
Thank you [~fhueske]. I was able to spot where the problem is and I will take
[~twalthr]'s advice before preparing a patch.
{code}
val generator = new CodeGenerator(config, inputDS.getType)
val condition = calcProgram.getCondition
val expandedExpressions = calcProgram.getProjectList.map(
expr => calcProgram.expandLocalRef(expr))
val projection = generator.generateResultExpression(
returnType,
rowType.getFieldNames,
expandedExpressions)
val body = {
// only projection
if (condition == null) {
s"""
|${projection.code}
|${generator.collectorTerm}.collect(${projection.resultTerm});
|""".stripMargin
}
else {
val filterCondition = generator.generateExpression(
calcProgram.expandLocalRef(calcProgram.getCondition))
// only filter
if (projection == null) {
// conversion
if (inputDS.getType != returnType) {
val conversion = generator.generateConverterResultExpression(
returnType,
rowType.getFieldNames)
{code}
Here 'generator.generateResultExpression' does some vaildatons on the result
types. But 'generator.generateExpression' that creates the filterCondition does
not do any validations. I am new to Scala so will take some time to see how to
fix this.
> CodeGenerator does not check type compatibility for equality expressions
> ------------------------------------------------------------------------
>
> Key: FLINK-3631
> URL: https://issues.apache.org/jira/browse/FLINK-3631
> Project: Flink
> Issue Type: Bug
> Components: Table API
> Affects Versions: 1.1.0
> Reporter: Fabian Hueske
>
> The following Table API query does not fail but produces an empty result:
> {code}
> val env = ExecutionEnvironment.getExecutionEnvironment
> val ds = CollectionDataSets.get3TupleDataSet(env).as('a, 'b, 'c)
> // must fail. Field 'a is not a string.
> ds.filter( 'a === "nope" ).collect()
> {code}
> The generated flatMap code looks like this:
> {code}
> @Override
> public void flatMap(Object _in1, org.apache.flink.util.Collector c) throws
> Exception {
> org.apache.flink.api.table.Row in1 = (org.apache.flink.api.table.Row) _in1;
>
> java.lang.String result$17 = (java.lang.String) in1.productElement(2);
> int result$11 = (java.lang.Integer) in1.productElement(0);
> long result$14 = (java.lang.Long) in1.productElement(1);
> java.lang.String result$19 = "nope";
>
> boolean result$21 = result$19.equals(result$11);
>
> if (result$21) {
> out.setField(0, result$11);
> out.setField(1, result$14);
> out.setField(2, result$17);
> c.collect(out);
> }
> }
> {code}
> I would expect the query to fail due to a Integer/String type conflict.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)