[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of fields in select statement

It has nothing to do with aliases. The type should match. As the message said, you are trying to insert varchar type into integer field, which doesn’t pass Calcite’s validation.

Thanks ~
Haisheng Yuan
日 期:2018年08月09日 00:07:58
主 题:Order of fields in select statement


I'm trying out Calcite and realized that Calcite does not support aliases
in select statement as well as it should be. Please let me know if I'm
missing something here.

Here is the scenario:

Let's say I have a destination with the following schema: { name: "field0",
type: "INTEGER" } , { name: "field1", type: "VARCHAR" }
and source with schema: { name: "field0", type: "INTEGER" } , { name:
"field1", type: "VARCHAR" }, { name: "field2", type: "BOOL" }

I have the following simple query: "INSERT INTO myDestination SELECT
s.field1 as field1, s.field0 as field0 FROM mySource as s"

Planner validation fails with "Cannot assign to target field 'field0' of
type INTEGER from source field 'field1' of type VARCHAR". It works if I
reverse the order of fields in the select statement. So, it looks like the
order of fields specified in the select statement should match the order of
fields in the output schema even if I use aliases. Is that true ?