linkedin/coral

Avoid converting `named_struct` to `CAST(ROW AS RowType)` in `CoralSqlNode2 -> RelNode` conversion

Closed this issue · 0 comments

Related discussion

In the translation path:

source SQL -> SourceLangSqlNode -> CoralSqlNode1 -> CoralRelNode -> CoralSqlNode2 -> TargetLangSqlNode -> target SQL

At present, for named_struct function in CoralSqlNode1, Calcite converts it to CAST(ROW AS RowType) in CoralRelNode, so in CoralSqlNode2, it's CAST(ROW AS RowType), which is different from named_struct in CoralSqlNode1. Note that only named_struct is a valid Coral IR.

So we should make the following changes:

  1. Avoid converting named_struct to CAST(ROW AS RowType) in CoralSqlNode2 -> RelNode conversion, and remove CastToNamedStructTransformer
  2. Add a transformer in coral-trino to convert named_struct to CAST(ROW AS RowType).