Skip to content

An open source alternative to Tableau. Embeddable visual analytic

10.3 KB
Raw Blame

Workflow Computation Divergences

This file records known differences between the client-side JavaScript workflow executor and SQL generated by @kanaries/gw-dsl-parser. Each entry includes the normative decision from computation.md and the corresponding conformance-test handling.

DVG-001: Log Transforms For Non-Positive Values

Minimal payload:

{
    "workflow": [
        {
            "type": "transform",
            "transform": [{ "key": "log_value", "expression": { "op": "log10", "as": "log_value", "params": [{ "type": "field", "value": "value" }] } }]
        },
        { "type": "view", "query": [{ "op": "raw", "fields": ["value", "log_value"] }] }
    ]
}

Data:

[{ "value": 10 }, { "value": 0 }, { "value": -5 }]

Client result: 1, -Infinity, and NaN.

SQL result: 1, null, and null.

Normative decision: SQL semantics. log, log2, and log10 return null for non-positive, nullish, or non-numeric input. This is safer for analytical backends and avoids serializing non-JSON numeric sentinels.

Test handling: test.failing in conformance, because the client behavior is still divergent.

DVG-002: binCount Is Quantile Bucketing In The Client And Equal-Width Bucketing In SQL

Minimal payload:

{
    "workflow": [
        {
            "type": "transform",
            "transform": [{ "key": "bucket", "expression": { "op": "binCount", "as": "bucket", "num": 3, "params": [{ "type": "field", "value": "value" }] } }]
        },
        { "type": "view", "query": [{ "op": "raw", "fields": ["value", "bucket"] }] }
    ]
}

Data:

[{ "value": 1 }, { "value": 2 }, { "value": 3 }, { "value": 100 }, { "value": 101 }, { "value": 102 }]

Client result: rank buckets 1, 1, 2, 2, 3, 3.

SQL result: equal-width buckets based on (value - min) / step.

Normative decision: client semantics. The operator name means count-balanced buckets; equal-width bucketing is already covered by bin.

Test handling: test.failing.

DVG-003: View-Level fold Is Unsupported By gw-dsl-parser

Minimal payload:

{
    "workflow": [{ "type": "view", "query": [{ "op": "fold", "foldBy": ["a", "b"], "newFoldKeyCol": "key", "newFoldValueCol": "value" }] }]
}

Data:

[{ "id": 1, "a": 10, "b": 20 }]

Client result: two rows, one for a and one for b.

SQL result: parser error: unknown variant 'fold', expected 'raw' or 'aggregate'.

Normative decision: client semantics. fold is part of the public IViewQuery type and has deterministic row expansion semantics.

Test handling: skipped conformance test with this entry id.

DVG-004: View-Level bin Is Unsupported By gw-dsl-parser

Minimal payload:

{
    "workflow": [{ "type": "view", "query": [{ "op": "bin", "binBy": "value", "newBinCol": "value_bin", "binSize": 3 }] }]
}

Data:

[{ "value": 1 }, { "value": 2 }, { "value": 3 }]

Client result: rows with a [min, max] bin tuple in value_bin.

SQL result: parser error: unknown variant 'bin', expected 'raw' or 'aggregate'.

Normative decision: same semantics as transform-level bin, applied in the view query sequence.

Test handling: skipped conformance test with this entry id.

DVG-005: one Transform Loses Its Alias In SQL

Minimal payload:

{
    "workflow": [
        { "type": "transform", "transform": [{ "key": "one", "expression": { "op": "one", "as": "one", "params": [] } }] },
        { "type": "view", "query": [{ "op": "raw", "fields": ["one"] }] }
    ]
}

Data:

[{ "value": 1 }]

Client result: { "one": 1 }.

SQL result: { "1": 1 }; generated SQL is SELECT 1 ... without AS "one".

Normative decision: transform output must use expression.as / key.

Test handling: test.failing.

DVG-006: Calendar Week Truncation Uses Different Week Starts

Minimal payload:

{
    "workflow": [
        {
            "type": "transform",
            "transform": [
                {
                    "key": "week",
                    "expression": {
                        "op": "dateTimeDrill",
                        "as": "week",
                        "params": [
                            { "type": "field", "value": "ts" },
                            { "type": "value", "value": "week" },
                            { "type": "offset", "value": 0 },
                            { "type": "displayOffset", "value": 0 }
                        ]
                    }
                }
            ]
        },
        { "type": "view", "query": [{ "op": "raw", "fields": ["week"] }] }
    ]
}

Data:

[{ "ts": 1704067200000 }]

Client result: Sunday-start week.

SQL result: DuckDB DATE_TRUNC('week', ...), which is Monday-start.

Normative decision: dateTimeDrill('week') is Sunday-start; iso_week is Monday-start.

Test handling: test.failing.

DVG-007: ISO Date Features Are Incorrectly Lowered In SQL

Minimal payload:

{
    "workflow": [
        {
            "type": "transform",
            "transform": [
                {
                    "key": "iso_week",
                    "expression": {
                        "op": "dateTimeFeature",
                        "as": "iso_week",
                        "params": [
                            { "type": "field", "value": "ts" },
                            { "type": "value", "value": "iso_week" },
                            { "type": "offset", "value": 0 },
                            { "type": "displayOffset", "value": 0 }
                        ]
                    }
                }
            ]
        },
        { "type": "view", "query": [{ "op": "raw", "fields": ["iso_week"] }] }
    ]
}

Data:

[{ "ts": 1704067200000 }]

Client result: ISO week number.

SQL result: generated SQL uses EXTRACT(YEAR ...) for iso_year, iso_week, and iso_weekday.

Normative decision: client ISO calendar semantics.

Test handling: test.failing.

DVG-008: Client Raw View Does Not Project Fields

Minimal payload:

{
    "workflow": [{ "type": "view", "query": [{ "op": "raw", "fields": ["a"] }] }]
}

Data:

[{ "a": 1, "b": 2 }]

Client result: { "a": 1, "b": 2 }.

SQL result: { "a": 1 }.

Normative decision: SQL/documented semantics. raw.fields is a projection list and output should not expose unlisted fields.

Test handling: test.failing.

DVG-009: Variance And Stdev Use Different Population/Sample Formulas

Minimal payload:

{
    "workflow": [
        {
            "type": "view",
            "query": [
                {
                    "op": "aggregate",
                    "groupBy": ["segment"],
                    "measures": [
                        { "field": "value", "agg": "variance", "asFieldKey": "variance_value" },
                        { "field": "value", "agg": "stdev", "asFieldKey": "stdev_value" }
                    ]
                }
            ]
        }
    ]
}

Data:

[
    { "segment": "A", "value": 1 },
    { "segment": "A", "value": 3 }
]

Client result: population variance 1 and stdev 1.

SQL result: generated SQL currently uses DuckDB aggregate behavior that does not match the client for these cases.

Normative decision: client semantics, because computation.md defines population variance and stdev. This decision should be revisited before a broader backend-compatibility release because many SQL engines and BI tools default to sample variance/stdev.

Test handling: test.failing.

DVG-010: Null Sort Ordering Differs

Minimal payload:

{
    "workflow": [
        { "type": "view", "query": [{ "op": "raw", "fields": ["segment", "value"] }] },
        { "type": "sort", "by": ["segment", "value"], "sort": "ascending" }
    ]
}

Data:

[
    { "segment": "A", "value": 1 },
    { "segment": null, "value": 2 }
]

Client result: nullish values are compared by String(value).

SQL result: DuckDB uses database null ordering unless the generated SQL makes null ordering explicit.

Normative decision: client comparator semantics; SQL generation should make null position explicit. This decision intentionally documents current behavior, but a future spec revision should consider explicit NULLS FIRST / NULLS LAST semantics instead of stringifying nullish values.

Test handling: test.failing.

DVG-012: Aggregate Null Handling Differs For Common Aggregators

Minimal payload:

{
    "workflow": [
        {
            "type": "view",
            "query": [
                {
                    "op": "aggregate",
                    "groupBy": ["segment"],
                    "measures": [
                        { "field": "value", "agg": "mean", "asFieldKey": "mean_value" },
                        { "field": "value", "agg": "count", "asFieldKey": "count_value" },
                        { "field": "value", "agg": "median", "asFieldKey": "median_value" }
                    ]
                }
            ]
        }
    ]
}

Data:

[
    { "segment": "A", "value": 1 },
    { "segment": "A", "value": null },
    { "segment": "A", "value": 3 }
]

Client result: mean_value = 1.3333333333333333, count_value = 3, median_value = 1.

SQL result: mean_value = 2, count_value = 2, median_value = 2.

Normative decision: client semantics for phase 1. count explicitly includes rows where the measured field is nullish; mean and median currently retain nullish rows and apply the client numeric comparator/coercion behavior. A later SQL-style null-exclusion revision would be breaking and should be made deliberately.

Test handling: test.failing.

DVG-011: Numeric Strings In SQL Expressions Are Not Coerced By DuckDB

Minimal payload:

{
    "workflow": [
        {
            "type": "transform",
            "transform": [
                { "key": "plus_one", "expression": { "op": "expr", "as": "plus_one", "params": [{ "type": "sql", "value": "\"number text\" + 1" }] } }
            ]
        },
        { "type": "view", "query": [{ "op": "raw", "fields": ["number text", "plus_one"] }] }
    ]
}

Data:

[{ "number text": "1" }]

Client result: numeric string is coerced and returns 2.

SQL result: DuckDB rejects VARCHAR + INTEGER without an explicit cast.

Normative decision: numeric strings coerce in numeric expression contexts for DSL portability.

Test handling: test.failing.