jvalue / ss24-zeltner-columnar-data

Place for experiments for the BA of Jonas Zeltner
0 stars 0 forks source link

[BUG] typescript backend crashes #1

Closed TungstnBallon closed 4 months ago

TungstnBallon commented 4 months ago

Steps to reproduce

  1. checkout the latest commit on the main branch
  2. run npm run example:testing

Description

Additional information

nx run interpreter:build:production [existing outputs match the cache, left as is]

nx run interpreter:run example/testing.jv

[CarsPipeline] Overview: Blocks (7 blocks with 1 pipes): -> CarsExtractor (HttpExtractor) -> CarsTextFileInterpreter (TextFileInterpreter) -> CarsCSVInterpreter (CSVInterpreter) -> NameHeaderWriter (CellWriter) -> CarsTableInterpreter (TableInterpreter) -> MyTableTransformer (TableTransformer) -> CarsLoader (SQLiteLoader)

    error: Could not write to sqlite database: column.getName is not a function
    $In /home/jonas/Code/uni/ss24-zeltner-columnar-data/example/testing.jv:64:9
    64 |   block CarsLoader oftype SQLiteLoader {
       |         ^^^^^^^^^^

Warning: run-commands command "node --enable-source-maps dist/apps/interpreter/main.js example/testing.jv" exited with non-zero status code


- It's really wierd that a TypeError occurs. IMO typescript should catch those at compiletime.
joluj commented 4 months ago

It looks that you don't use the TsTableColumn constructor somewhere. The Type is unexpectedly Object in debug-log-vistor.ts:54: image

joluj commented 4 months ago

In table.ts:446 you use structuredClone. This function creates a clone with the attributes only, i.e. the result is basically what you get if you copy a JSON object. That object is a plain JS object without any class information, that's why the type of the columns after cloning a table is just Object and not TsTableColumn (see screenshot above). The best approach is to create a custom clone method in TsTableColumn and PolarsTableColumn.

TungstnBallon commented 4 months ago

Thanks, that worked