Repository: feldera/feldera

Issue #386: SQL Compiler should not optimize away unused tables
Created: 2023-07-22T05:30:22Z
I ran into this when compiling the secops demo. There are some tables that aren't used by views in this example. But since the tables exist in the schema, the UI displays them. For a user (me), it is confusing that I couldn't send anything to the table or read from. Instead it throws an  error that the table doesn't exist.
I think it's also valuable for a user to be able to send data to unused tables just for testing (first thing one might do is create a table and try to send some data to it). So it would be good if tables that are declared in the SQL don't get optimized away.

Duplicate issue #66: [JIT] Jit compiler panic
Created: 2023-05-12T07:36:59Z
Issue by mihaibudiu
Fri Apr 14 22:51:03 2023
Originally opened as vmware-archive/database-stream-processor#372

Yet another kind of panic:
thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `String`,
 right: `String`', crates/dataflow-jit/src/ir/validate.rs:970:17

JSON:
{
  "nodes" : {
    "11797" : {
      "Source" : {
        "layout" : 1,
        "table" : "T"
      }
    },
    "11841" : {
      "Map" : {
        "input" : 11797,
        "map_fn" : {
          "args" : [ {
            "id" : 1,
            "layout" : 1,
            "flags" : "input"
          }, {
            "id" : 2,
            "layout" : 2,
            "flags" : "output"
          } ],
          "ret" : "Unit",
          "entry_block" : 1,
          "blocks" : {
            "1" : {
              "id" : 1,
              "body" : [ [ 3, {
                "Load" : {
                  "source" : 1,
                  "source_layout" : 3,
                  "column" : 3,
                  "column_type" : "String"
                }
              } ], [ 4, {
                "Constant" : {
                  "String" : " "
                }
              } ], [ 5, {
                "Constant" : {
                  "Bool" : false
                }
              } ], [ 6, {
                "BinOp" : {
                  "lhs" : 3,
                  "rhs" : 4,
                  "kind" : "Or",
                  "operand_ty" : "String"
                }
              } ], [ 7, {
                "Load" : {
                  "source" : 1,
                  "source_layout" : 3,
                  "column" : 3,
                  "column_type" : "String"
                }
              } ], [ 8, {
                "Constant" : {
                  "Bool" : false
                }
              } ], [ 9, {
                "BinOp" : {
                  "lhs" : 6,
                  "rhs" : 7,
                  "kind" : "Or",
                  "operand_ty" : "String"
                }
              } ], [ 10, {
                "Store" : {
                  "target" : 2,
                  "target_layout" : 2,
                  "column" : 0,
                  "value" : {
                    "Expr" : 9
                  },
                  "value_type" : "String"
                }
              } ] ],
              "terminator" : {
                "Return" : {
                  "value" : {
                    "Imm" : "Unit"
                  }
                }
              }
            }
          }
        },
        "layout" : 2
      }
    },
    "11843" : {
      "Sink" : {
        "input" : 11841,
        "query" : "CREATE VIEW V AS SELECT T.COL4 || ' ' || T.COL4 FROM T"
      }
    }
  },
  "layouts" : {
    "1" : {
      "columns" : [ {
        "nullable" : false,
        "ty" : "I32"
      }, {
        "nullable" : false,
        "ty" : "F64"
      }, {
        "nullable" : false,
        "ty" : "Bool"
      }, {
        "nullable" : false,
        "ty" : "String"
      }, {
        "nullable" : true,
        "ty" : "I32"
      }, {
        "nullable" : true,
        "ty" : "F64"
      } ]
    },
    "2" : {
      "columns" : [ {
        "nullable" : false,
        "ty" : "String"
      } ]
    },
    "3" : {
      "columns" : [ {
        "nullable" : false,
        "ty" : "I32"
      }, {
        "nullable" : false,
        "ty" : "F64"
      }, {
        "nullable" : false,
        "ty" : "Bool"
      }, {
        "nullable" : false,
        "ty" : "String"
      }, {
        "nullable" : true,
        "ty" : "I32"
      }, {
        "nullable" : true,
        "ty" : "F64"
      } ]
    }
  }
}

Closing comment (2023-05-12T07:37:01Z): Comment by mihaibudiu
Fri Apr 28 23:59:57 2023

Here is am improved JSON program, which causes a different panic, similar to #386
{
  "nodes" : {
    "78" : {
      "Source" : {
        "layout" : 1,
        "table" : "T"
      }
    },
    "123" : {
      "Map" : {
        "input" : 78,
        "map_fn" : {
          "args" : [ {
            "id" : 1,
            "layout" : 1,
            "flags" : "input"
          }, {
            "id" : 2,
            "layout" : 2,
            "flags" : "output"
          } ],
          "ret" : "Unit",
          "entry_block" : 1,
          "blocks" : {
            "1" : {
              "id" : 1,
              "body" : [ [ 3, {
                "Load" : {
                  "source" : 1,
                  "source_layout" : 3,
                  "column" : 3,
                  "column_type" : "String"
                }
              } ], [ 4, {
                "Constant" : {
                  "String" : " "
                }
              } ], [ 5, {
                "Call" : {
                  "function" : "dbsp.str.concat_clone",
                  "args" : [ 3, 4 ],
                  "arg_types" : [ {
                    "Scalar" : "String"
                  }, {
                    "Scalar" : "String"
                  } ],
                  "ret_ty" : "String"
                }
              } ], [ 6, {
                "Load" : {
                  "source" : 1,
                  "source_layout" : 3,
                  "column" : 3,
                  "column_type" : "String"
                }
              } ], [ 7, {
                "Call" : {
                  "function" : "dbsp.str.concat_clone",
                  "args" : [ 5, 6 ],
                  "arg_types" : [ {
                    "Scalar" : "String"
                  }, {
                    "Scalar" : "String"
                  } ],
                  "ret_ty" : "String"
                }
              } ], [ 8, {
                "Store" : {
                  "target" : 2,
                  "target_layout" : 2,
                  "column" : 0,
                  "value" : {
                    "Expr" : 7
                  },
                  "value_type" : "String"
                }
              } ] ],
              "terminator" : {
                "Return" : {
                  "value" : {
                    "Imm" : "Unit"
                  }
                }
              }
            }
          }
        },
        "output_layout" : {
          "Set" : 2
        },
        "input_layout" : {
          "Set" : 1
        }
      }
    },
    "125" : {
      "Sink" : {
        "input" : 123,
        "query" : "CREATE VIEW V AS SELECT T.COL4 || ' ' || T.COL4 FROM T"
      }
    }
  },
  "layouts" : {
    "1" : {
      "columns" : [ {
        "nullable" : false,
        "ty" : "I32"
      }, {
        "nullable" : false,
        "ty" : "F64"
      }, {
        "nullable" : false,
        "ty" : "Bool"
      }, {
        "nullable" : false,
        "ty" : "String"
      }, {
        "nullable" : true,
        "ty" : "I32"
      }, {
        "nullable" : true,
        "ty" : "F64"
      } ]
    },
    "2" : {
      "columns" : [ {
        "nullable" : false,
        "ty" : "String"
      } ]
    },
    "3" : {
      "columns" : [ {
        "nullable" : false,
        "ty" : "I32"
      }, {
        "nullable" : false,
        "ty" : "F64"
      }, {
        "nullable" : false,
        "ty" : "Bool"
      }, {
        "nullable" : false,
        "ty" : "String"
      }, {
        "nullable" : true,
        "ty" : "I32"
      }, {
        "nullable" : true,
        "ty" : "F64"
      } ]
    }
  }
}