|
@@ -48,6 +48,7 @@ import org.elasticsearch.xpack.sql.expression.function.aggregate.Max;
|
|
|
import org.elasticsearch.xpack.sql.expression.function.aggregate.Min;
|
|
import org.elasticsearch.xpack.sql.expression.function.aggregate.Min;
|
|
|
import org.elasticsearch.xpack.sql.expression.function.aggregate.Skewness;
|
|
import org.elasticsearch.xpack.sql.expression.function.aggregate.Skewness;
|
|
|
import org.elasticsearch.xpack.sql.expression.function.aggregate.TopHits;
|
|
import org.elasticsearch.xpack.sql.expression.function.aggregate.TopHits;
|
|
|
|
|
+import org.elasticsearch.xpack.sql.expression.function.scalar.Cast;
|
|
|
import org.elasticsearch.xpack.sql.plan.logical.Distinct;
|
|
import org.elasticsearch.xpack.sql.plan.logical.Distinct;
|
|
|
import org.elasticsearch.xpack.sql.plan.logical.LocalRelation;
|
|
import org.elasticsearch.xpack.sql.plan.logical.LocalRelation;
|
|
|
import org.elasticsearch.xpack.sql.plan.logical.Pivot;
|
|
import org.elasticsearch.xpack.sql.plan.logical.Pivot;
|
|
@@ -220,6 +221,7 @@ public final class Verifier {
|
|
|
checkForGeoFunctionsOnDocValues(p, localFailures);
|
|
checkForGeoFunctionsOnDocValues(p, localFailures);
|
|
|
checkPivot(p, localFailures, attributeRefs);
|
|
checkPivot(p, localFailures, attributeRefs);
|
|
|
checkMatrixStats(p, localFailures);
|
|
checkMatrixStats(p, localFailures);
|
|
|
|
|
+ checkCastOnInexact(p, localFailures);
|
|
|
|
|
|
|
|
// everything checks out
|
|
// everything checks out
|
|
|
// mark the plan as analyzed
|
|
// mark the plan as analyzed
|
|
@@ -865,4 +867,19 @@ public final class Verifier {
|
|
|
}
|
|
}
|
|
|
}, Skewness.class));
|
|
}, Skewness.class));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private static void checkCastOnInexact(LogicalPlan p, Set<Failure> localFailures) {
|
|
|
|
|
+ p.forEachDown(f -> f.forEachExpressionsUp(e -> e.forEachUp((Cast c) -> {
|
|
|
|
|
+ if (c.field() instanceof FieldAttribute) {
|
|
|
|
|
+ EsField.Exact exactInfo = ((FieldAttribute) c.field()).getExactInfo();
|
|
|
|
|
+ if (exactInfo.hasExact() == false
|
|
|
|
|
+ || ((FieldAttribute) c.field()).exactAttribute().equals(c.field()) == false) {
|
|
|
|
|
+ localFailures.add(fail(c.field(),
|
|
|
|
|
+ "[{}] of data type [{}] cannot be used for [{}()] inside the WHERE clause",
|
|
|
|
|
+ c.field().sourceText(), c.field().dataType().typeName(), c.functionName()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }, Cast.class)), Filter.class);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|