-
Notifications
You must be signed in to change notification settings - Fork 690
Description
Hi! I’m currently working on building a Docker image for AlaSQL and I’ve run into an issue where commands passed to the container aren’t being executed as expected.
From what I’ve investigated so far, it seems that Docker doesn’t attach a TTY by default when running commands through ENTRYPOINT, which changes how the CLI behaves. I tried updating the logic in alasql-cli.js, but I think there may be another underlying issue as well.
Specifically, when piping data into a query, the input is being treated as a SQL statement rather than as data. I can reproduce this behavior both inside and outside of Docker, so it doesn’t appear to be container-specific. Looking at the code in alasql-cli.js, it seems to try to read input directly, whereas I had expected file or stream reading to be handled by the standard FROM helpers such as alasql.from.TXT, which ultimately call alasql.utils.loadFile.
I may be misunderstanding the intended behavior — but it seems like the CLI is handling input differently than the query engine’s built-in file readers. I’d really appreciate any clarification on this, or advice on how best to approach making AlaSQL run reliably inside Docker. Thanks!
Steps to replicate docker issue:
- Check out my fork of the repo
- Run the following command to build the alasql docker image:
docker build -t alasql-test .- run the following command to replicate the issue:
docker run alasql-test "SELECT 1 + 1"Expected output:
[
{
"1 + 1": 2
}
]Actual output:
No SQL to process
AlaSQL command-line utility (version 4.6.6)
Usage: alasql [options] [sql] [params]
Options:
-v, --version Echo AlaSQL version [boolean]
-m, --minify Minify json output [boolean]
-f, --file Load SQL from file [string]
--ast Print AST instead of result [string]
-h, --help Show help [boolean]
Examples:
alasql "sql-statement" Run SQL statement and output result
as JSON
alasql 'value of select 2+?' 40 Outputs 42
alasql 'select count(*) from txt()' < Count lines in city.txt
city.txt
alasql 'select * into xlsx("city.xlsx") Convert from txt to xlsx
from txt("city.txt")'
alasql --file file.sql France 1960 Run SQL from file with 2 parameters
Steps to replicate pipe issue:
- Run the below command:
echo "I am test data" >> test.txt
alasql "SELECT COUNT(*) FROM txt()" < test.txtExpected output:
[
{
"COUNT(*)": 1
}
]Actual output:
{
"error": {
"stack": "SyntaxError: Parse error on line 1:\nI am test data\n--^\nExpecting 'EOF', 'COMMA', 'LPAR', 'RPAR', 'END', 'ELSE', 'COLONDASH', 'GO', 'SEMICOLON', got 'LITERAL'\n at parser.pars...",
"message": "Parse error on line 1:\nI am test data\n--^\nExpecting 'EOF', 'COMMA', 'LPAR', 'RPAR', 'END', 'ELSE', 'COLONDASH', 'GO', 'SEMICOLON', got 'LITERAL'"
}
}