vmware-archive / database-stream-processor

Streaming and Incremental Computation Framework
Other
222 stars 20 forks source link

[JIT] Cannot validate Constant operators #393

Closed mihaibudiu closed 1 year ago

mihaibudiu commented 1 year ago

I cannot tell what the problem is with the following program; it produces the following error:

json validation error at /nodes/122: {"Constant":{"comment":"{ Tuple1::new(0i32) => 1}","layout":{"Set":2},"value":{"Set":[[{"rows":[{"NonNull":{"I32":0}}]},1]],"layout":{"Set":2}}}} is not valid under any of the given schemas ValidationError { instance: Object {"Constant": Object {"comment": String("{ Tuple1::new(0i32) => 1}"), "layout": Object {"Set": Number(2)}, "value": Object {"Set": Array [Array [Object {"rows": Array [Object {"NonNull": Object {"I32": Number(0)}}]}, Number(1)]], "layout": Object {"Set": Number(2)}}}}, kind: OneOfNotValid, instance_path: JSONPointer([Property("nodes"), Property("122")]), schema_path: JSONPointer([Keyword("properties"), Property("nodes"), Keyword("additionalProperties"), Keyword("oneOf")]) }

{
  "nodes" : {
    "78" : {
      "Source" : {
        "layout" : 1,
        "table" : "T"
      }
    },
    "122" : {
      "Constant" : {
        "comment" : "{ Tuple1::new(0i32) => 1}",
        "layout" : {
          "Set" : 2
        },
        "value" : {
          "layout" : {
            "Set" : 2
          },
          "Set" : [ [ {
            "rows" : [ {
              "NonNull" : {
                "I32" : 0
              }
            } ]
          }, 1 ] ]
        }
      }
    },
    "131" : {
      "Map" : {
        "input" : 122,
        "map_fn" : {
          "args" : [ {
            "id" : 1,
            "layout" : 2,
            "flags" : "input"
          }, {
            "id" : 2,
            "layout" : 2,
            "flags" : "output"
          } ],
          "ret" : "Unit",
          "entry_block" : 1,
          "blocks" : {
            "1" : {
              "id" : 1,
              "body" : [ [ 3, {
                "Constant" : {
                  "I32" : 3
                }
              } ], [ 4, {
                "Store" : {
                  "target" : 2,
                  "target_layout" : 2,
                  "column" : 0,
                  "value" : {
                    "Expr" : 3
                  },
                  "value_type" : "I32"
                }
              } ] ],
              "terminator" : {
                "Return" : {
                  "value" : {
                    "Imm" : "Unit"
                  }
                }
              }
            }
          }
        },
        "output_layout" : {
          "Set" : 2
        },
        "input_layout" : {
          "Set" : 2
        }
      }
    },
    "133" : {
      "Sink" : {
        "input" : 131,
        "query" : "CREATE VIEW V AS SELECT 1 + 2"
      }
    }
  },
  "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" : "I32"
      } ]
    }
  }
}
Kixiron commented 1 year ago

Your json is incorrect, it should be like this

{
    "nodes": {
        "78": {
            "Source": {
                "layout": 1,
                "table": "T"
            }
        },
        "122": {
            "ConstantStream": {
                "value": {
                    "layout": {
                        "Set": 2
                    },
                    "value": {
                        "Set": [
                            [
                                {
                                    "rows": [
                                        {
                                            "NonNull": {
                                                "I32": 0
                                            }
                                        }
                                    ]
                                },
                                1
                            ]
                        ]
                    }
                },
                "layout": {
                    "Set": 2
                },
                "consolidated": false
            }
        },
        "131": {
            "Map": {
                "input": 122,
                "map_fn": {
                    "args": [
                        {
                            "id": 1,
                            "layout": 2,
                            "flags": "input"
                        },
                        {
                            "id": 2,
                            "layout": 2,
                            "flags": "output"
                        }
                    ],
                    "ret": "Unit",
                    "entry_block": 1,
                    "blocks": {
                        "1": {
                            "id": 1,
                            "body": [
                                [
                                    3,
                                    {
                                        "Constant": {
                                            "I32": 3
                                        }
                                    }
                                ],
                                [
                                    4,
                                    {
                                        "Store": {
                                            "target": 2,
                                            "target_layout": 2,
                                            "column": 0,
                                            "value": {
                                                "Expr": 3
                                            },
                                            "value_type": "I32"
                                        }
                                    }
                                ]
                            ],
                            "terminator": {
                                "Return": {
                                    "value": {
                                        "Imm": "Unit"
                                    }
                                }
                            }
                        }
                    }
                },
                "output_layout": {
                    "Set": 2
                },
                "input_layout": {
                    "Set": 2
                }
            }
        },
        "133": {
            "Sink": {
                "input": 131,
                "query": "CREATE VIEW V AS SELECT 1 + 2"
            }
        }
    },
    "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": "I32"
                }
            ]
        }
    }
}