Skip to content

[SQL] SAFE_CAST(NULL AS USER DEFINED type) passes SQL but fails Rust compilation #5390

@rivudhk

Description

@rivudhk

Following SQL:

CREATE TYPE user_def AS(i1 INT, v1 VARCHAR NULL);
CREATE TYPE user_def_row AS (val ROW(i1 INT, v1 VARCHAR NULL));
CREATE TYPE user_def_udt AS (val user_def);

CREATE TABLE tbl(
arr VARCHAR ARRAY,
mapp MAP<VARCHAR, INT>,
roww ROW(i1 INT, v1 VARCHAR NULL) NULL,
udt user_def);


CREATE MATERIALIZED VIEW v AS SELECT
SAFE_CAST(NULL AS user_def_row) AS to_row,
SAFE_CAST(NULL AS user_def_udt) AS to_udt
FROM tbl;

Passes SQL but fails Rust compilation the following errors:

 error[E0277]: the trait bound `Tup1<Option<Tup2<Option<i32>, Option<SqlString>>>>: From<...>` is not satisfied
   --> crates/feldera_pipe_operator_5d8d4698bc6522df/src/lib.rs:159:19
    |
159 |                 x.into()), )
    |                   ^^^^ the trait `From<struct_1687b1b3750fc701>` is not implemented for `Tup1<Option<Tup2<Option<i32>, Option<SqlString>>>>`
    |
    = help: the following other types implement trait `From<T>`:
              `dbsp::utils::Tup1<T1>` implements `From<(T1,)>`
              `Tup1<Option<Tup2<i32, Option<SqlString>>>>` implements `From<struct_1687b1b3750fc701>`
    = note: required for `struct_1687b1b3750fc701` to implement `Into<Tup1<Option<Tup2<Option<i32>, Option<SqlString>>>>>`
    = note: the full name for the type has been written to '/Users/rivuadhikari/.feldera/compiler/rust-compilation/target/debug/deps/feldera_pipe_operator_5d8d4698bc6522df-caf54392dfeba4f4.long-type-57774922162027651.txt'
    = note: consider using `--verbose` to print the full type name to the console
 error[E0277]: the trait bound `struct_1687b1b3750fc701: From<Tup1<Option<Tup2<Option<i32>, ...>>>>` is not satisfied
   --> crates/feldera_pipe_operator_5d8d4698bc6522df/src/lib.rs:168:23
    |
168 |                     x.into()), 
    |                       ^^^^ unsatisfied trait bound
    |
    = help: the trait `From<dbsp::utils::Tup1<std::option::Option<dbsp::utils::Tup2<std::option::Option<i32>, _>>>>` is not implemented for `struct_1687b1b3750fc701`
            but trait `From<dbsp::utils::Tup1<std::option::Option<dbsp::utils::Tup2<i32, _>>>>` is implemented for it
    = help: for that trait implementation, expected `i32`, found `std::option::Option<i32>`
    = note: required for `Tup1<Option<Tup2<Option<i32>, Option<SqlString>>>>` to implement `Into<struct_1687b1b3750fc701>`
    = note: the full name for the type has been written to '/Users/rivuadhikari/.feldera/compiler/rust-compilation/target/debug/deps/feldera_pipe_operator_5d8d4698bc6522df-caf54392dfeba4f4.long-type-57774922162027651.txt'
    = note: consider using `--verbose` to print the full type name to the console

Metadata

Metadata

Assignees

Labels

SQL compilerRelated to the SQL compiler

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions