vmware-archive / sql-to-dbsp-compiler

Compiler translating SQL view definitions into DBSP circuits (https://github.com/vmware/database-stream-processor)
Other
28 stars 4 forks source link

JIT codegen produces invalid strings #151

Open Kixiron opened 1 year ago

Kixiron commented 1 year ago

The code generated for the jit is invalid and doesn't properly respect strings, e.g.

[
    8,
    {
        "Load": {
            "source": 1,
            "source_layout": 6,
            "column": 1,
            "column_type": "String"
        }
    }
],
[
    9,
    {
        "IsNull": {
            "target": 1,
            "target_layout": 6,
            "column": 1
        }
    }
],
[
    10,
    {
        "Store": {
            "target": 3,
            "target_layout": 2,
            "column": 1,
            "value": {
                "Expr": 8
            },
            "value_type": "String"
        }
    }
],
[
    11,
    {
        "SetNull": {
            "target": 3,
            "target_layout": 2,
            "column": 1,
            "is_null": {
                "Expr": 9
            }
        }
    }
],

Values being stored should be owned, and the value loaded from an input is not owned. In order to create an owned string you should call Copy and then store the resulting value. Additionally, the null-ness of the string isn't respected, you can't operate over (things like calling Copy, for example) a null string so basic blocks/branches/jumps should be used in order to only perform cloning and such over strings when they're not null