Skip to content

Preserve Python literals in generated catalog queries - #73

Open
zack-dev-cm wants to merge 3 commits into
neuralinkcorp:mainfrom
zack-dev-cm:fix/catalog-python-literals
Open

zack-dev-cm wants to merge 3 commits into
neuralinkcorp:mainfrom
zack-dev-cm:fix/catalog-python-literals

Conversation

@zack-dev-cm

@zack-dev-cm zack-dev-cm commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Catalog filters containing lists, booleans, quotes or backslashes can generate Python that changes the value or the number of Filter arguments. For example, an integer list becomes several arguments, while an empty list drops the value argument.

Render transported scalar/list values as Python literals and escape string arguments consistently. Unsafe integral JavaScript numbers use exponential floating-point tokens to preserve their transported numeric value. Filter operators, unary-null behavior and SQL formatting are preserved.

Unsupported runtime objects and nonfinite numbers, including unsupported values nested inside lists, produce the comment-only snippet # cannot render this filter value. The table page continues rendering, and the example cannot silently omit an unsupported filter. The 39 regressions exercise the real exporter and compiled TypeScript generator, execute supported snippets against a recording API, and include local Parquet queries.

The branch includes current main and the merged credential correction from #74. The PR diff contains only the generator, its filter-value type and the regression module.

Validation:

  • All seven new placeholder regressions fail with TypeError on the previous PR revision and pass with this correction.
  • Full suite: 289 passed and 16 opt-in ClickHouse integration tests skipped with both boto3/botocore 1.43.93 and minimum boto3 1.26.20 / botocore 1.29.20.
  • All 39 generator regressions and the installed-wheel smoke test pass outside the checkout. The wheel's generator/type sources match the submitted source.
  • Static catalog and wheel builds, Black, flake8 error checks and mypy pass. Chrome verification retains the unsupported table's heading, partitions and schema alongside the placeholder; a supported table renders the expected query with no browser errors.
  • Current-head tests and code quality and installed-wheel checks on Python 3.10/3.12 pass. The two publication jobs are skipped.

This preserves the value available after JSON/JavaScript transport; it cannot recover precision or distinguish 1.0 from 1 after that information has already been lost.

@neuralink-code-review-bot neuralink-code-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No material correctness, security, API, test-gap, or error-handling issues in this diff. formatPythonLiteral correctly switches generated catalog code from unescaped interpolation/Array.toString() to Python literals (JSON-escaped strings, True/False/None, bracketed lists), which fixes the reported argument-splitting and empty-list bugs without changing unary-null or SQL formatting. Unsafe integral JS numbers are emitted with toExponential() so Python does not parse a different integer value; non-finite numbers and non-JSON objects fail loudly with TypeError as documented. The new exporter/tsc round-trip tests cover escaping, nested lists, signed zero, large floats, selected columns, and local Parquet execution.

Posted by the code review bot. This is an automated review, not a maintainer approval.

@saarthak2002 saarthak2002 self-assigned this Sep 25, 2026
Serialize scalar and nested list values, escape string arguments, and preserve large floating-point values through Python token generation. Add exporter-to-generator execution and local Parquet regressions.
@zack-dev-cm
zack-dev-cm force-pushed the fix/catalog-python-literals branch from abc6188 to 0159422 Compare October 2, 2026 06:03

@neuralink-code-review-bot neuralink-code-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No material issues in this change. Filter/name/column values are now emitted as real Python literals, which fixes the argument-splitting and silent-corruption cases (lists, empty lists, quotes, booleans, null, unsafe integrals) without altering unary-null handling or SQL predicate formatting. JSON.stringify for strings, True/False/None, recursive lists, -0.0, and toExponential() for non-safe integers are the right round-trip choices after JSON/JS transport; unsupported objects and non-finite numbers fail closed with TypeError. The new exporter/tsc/exec tests cover the behavioral surface, including nested lists, escaping, and a local Parquet query.

Posted by the code review bot. This is an automated review, not a maintainer approval.

return Object.is(value, -0) ? '-0.0' : String(value)
}
if (Array.isArray(value)) return '[' + value.map(formatPythonLiteral).join(', ') + ']'
throw new TypeError('Cannot generate a Python literal for this filter value')

@saarthak2002 saarthak2002 Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zack-dev-cm instead of throwing a TypeError in formatPythonLiteral for unsupported values (which would break the table page render), could the snippet emit a placeholder like # cannot render this filter value instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, corrected. Unsupported filter values now display # cannot render this filter value without breaking the table page. Regression tests and all required CI checks pass. Thanks for catching this!

@neuralink-code-review-bot neuralink-code-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No material correctness, security, API, or test-gap issues in this diff. Rendering filter values with explicit Python literals (and JSON.stringify for names/strings) fixes the previous argument-splitting and escaping bugs, and unsupported or non-finite values fail closed with a non-executable placeholder instead of emitting a wrong Filter call. Number formatting matches the stated JSON/JS transport limits (including unsafe integrals via exponential tokens and signed zero), and the new exporter/tsc regressions cover the behavioral changes.

Posted by the code review bot. This is an automated review, not a maintainer approval.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants