Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] typescript backend crashes #1

Closed
TungstnBallon opened this issue May 29, 2024 · 3 comments · Fixed by #2
Closed

[BUG] typescript backend crashes #1

TungstnBallon opened this issue May 29, 2024 · 3 comments · Fixed by #2
Labels
bug Something isn't working

Comments

@TungstnBallon
Copy link
Collaborator

Steps to reproduce

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

Description

  • Expected: A cars.sqlite file is created without errors
  • Actual: The interpreter crashes when trying to print the table
        error: An unknown error occurred: TypeError: column.getValueType is not a function
    at file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:10222:40
    at Array.map (<anonymous>)
    at DebugLogVisitor.visitTsTable (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:10221:40)
    at _TsTable.acceptVisitor (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:11153:20)
    at TsTableTransformerExecutor.logBlockResult (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:10371:12)
    at TsTableTransformerExecutor.execute (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:10351:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async executeBlock (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:11356:14)
    at async executeBlocks (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:11325:29)
    at async runPipeline (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:14252:27)
    at async Promise.all (index 0)
    at async interpretJayveeModel (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:14219:21)
    at async interpretModel (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:14177:34)
    at async Command.runAction (file:///home/jonas/Code/uni/ss24-zeltner-columnar-data/dist/apps/interpreter/main.js:14313:20)
        $In /home/jonas/Code/uni/ss24-zeltner-columnar-data/example/testing.jv:57:9
        57 |   block MyTableTransformer oftype TableTransformer {
           |         ^^^^^^^^^^^^^^^^^^

        [MyTableTransformer] Execution duration: 67 ms.
Warning: run-commands command "node --enable-source-maps dist/apps/interpreter/main.js -d example/testing.jv -dg peek" exited with non-zero status code

Additional information

  • When running without trying to print the table, the interpreter still crashes
❯ npx nx run interpreter:run -- example/testing.jv

   ✔    6/6 dependent project tasks succeeded [6 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————


> 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.
@TungstnBallon TungstnBallon added the bug Something isn't working label May 29, 2024
@joluj
Copy link
Contributor

joluj commented May 31, 2024

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

@joluj
Copy link
Contributor

joluj commented May 31, 2024

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
Copy link
Collaborator Author

Thanks, that worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants