Skip to content

Add computed select projections#22

Merged
dodok8 merged 29 commits into
mainfrom
issue-13-computed-select-projections
Jun 19, 2026
Merged

Add computed select projections#22
dodok8 merged 29 commits into
mainfrom
issue-13-computed-select-projections

Conversation

@dodok8

@dodok8 dodok8 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add computed select projections with alias := expr syntax for numeric arithmetic value expressions.

Closes #13

Scope

  • Document computed projection contracts in spec/query.md, spec/ir.md, and spec/sqlite-query-plan.md.
  • Add := tokenization and parser support for computed shape items.
  • Represent schema-backed and computed shape items separately in AST and Semantic IR.
  • Resolve computed projections into query-local IR values without pretending they are schema fields.
  • Lower computed projections through SQLite planning and SQL generation.
  • Add query-pipeline coverage from query text through actual SQLite execution.

Spec and plan alignment

List the spec/ and plan/ files checked for this change. If the change
intentionally diverges from them, explain why and include the required document
update in this pull request.

Tests

List the automated and manual checks performed.

  • cargo test --workspace
  • Other: targeted crate tests were run while implementing each layer (query-ir, query-resolver, sqlite-query-plan, sqlite-query-sqlgen, and query-pipeline-tests).

Review notes

Call out API boundaries, temporary rules, migration concerns, or follow-up work
that reviewers should inspect closely.

  • ResolvedShapeItem now separates schema-backed fields from computed fields. ResolvedShapeField::field() remains schema-backed only.
  • ResolvedShape::fields() is currently a compatibility view over schema-backed fields. New result-shape code should prefer items().
  • The first computed projection milestone accepts arithmetic value expressions that depend on a row path. Plain paths, literal-only arithmetic, duplicate output names, boolean expressions, membership expressions, and unsupported value forms are rejected before SQLite planning.
  • SQL generation now renders SELECT-list value expressions and aliases computed values with their output name.

AI assistance

Disclose AI tool usage according to AI_POLICY.md.

  • No AI tools were used.
  • AI tools were used and are disclosed here and in the relevant commit
    messages with Assisted-by trailers.

Tools and models:

  • Codex:gpt-5.5

dodok8 added 18 commits June 16, 2026 16:40
Document query, IR, and SQLite planning contracts for query-local computed select projections.

Assisted-by: Codex:gpt-5.5
Capture the token contract for the := shape assignment syntax before implementing lexer support.

Assisted-by: Codex:gpt-5.5
Add a dedicated query lexer token for := so computed shape items can be distinguished from nested shape syntax.

Assisted-by: Codex:gpt-5.5
Capture the AST contract for query-local computed projection items before adding parser support.

Assisted-by: Codex:gpt-5.5
Add a query-local computed shape item variant while preserving the existing schema-backed shape item constructor.

Assisted-by: Codex:gpt-5.5
Capture parsing for alias-assigned arithmetic projections in select shapes.

Assisted-by: Codex:gpt-5.5
Teach select shape parsing to build computed AST items from alias-assigned expressions while preserving nested shape parsing.

Assisted-by: Codex:gpt-5.5
Capture the Semantic IR contract for query-local computed projection items without schema field references.

Assisted-by: Codex:gpt-5.5
Add resolved shape item variants so schema-backed fields and computed projection values keep separate IR invariants.

Assisted-by: Codex:gpt-5.5
Capture resolution from computed AST shape items to query-local computed IR shape items.

Assisted-by: Codex:gpt-5.5
Map computed AST shape items to computed Semantic IR items without treating them as schema-backed fields.

Assisted-by: Codex:gpt-5.5
Cover unsupported computed projection value forms and duplicate output names at semantic resolution.

Assisted-by: Codex:gpt-5.5
Reject unsupported computed projection forms and duplicate shape output names during semantic resolution.

Assisted-by: Codex:gpt-5.5
Capture planning for computed select projection values before extending selected value slots.

Assisted-by: Codex:gpt-5.5
Lower computed shape items to SQLite value expressions while preserving schema-backed field projection behavior.

Assisted-by: Codex:gpt-5.5
Capture SELECT-list rendering and bind ordering for computed projection value expressions.

Assisted-by: Codex:gpt-5.5
Render SELECT-list value expressions with aliases for computed projections while preserving bind ordering.

Assisted-by: Codex:gpt-5.5
Add render and execution coverage for computed select projections from query text through SQLite execution.

Assisted-by: Codex:gpt-5.5
@dodok8

dodok8 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02cd7f205b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/sqlite-query-plan/src/lib.rs Outdated
Comment thread spec/ir.md
Comment thread tests/query-pipeline/tests/select_execution.rs Outdated
dodok8 added 4 commits June 19, 2026 12:31
Specify that computed projection paths are resolved and planned relative to the shape that contains them.

Assisted-by: Codex:gpt-5.5
Use a timestamp-counter suffix instead of mixing both values into one integer for pipeline test schema files.

Assisted-by: Codex:gpt-5.5
Pass the containing shape alias into SQLite value planning and prefix nested path traversal aliases to avoid collisions.

Assisted-by: Codex:gpt-5.5
Configure SonarCloud CPD exclusions for Rust crate-local test modules.

Assisted-by: Codex:gpt-5.5
@sonarqubecloud

Copy link
Copy Markdown

@dodok8

dodok8 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a49ed6e80

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/sqlite-query-sqlgen/src/lib.rs Outdated
Comment thread spec/ir.md
Comment thread engine/sqlite-query-plan/src/lib.rs Outdated
dodok8 added 3 commits June 19, 2026 13:06
Narrow the Semantic IR non-goal to schema-level computed fields so query-local computed projections remain in scope.

Assisted-by: Codex:gpt-5.5
Represent field-backed and computed selected values with typed variants and fallible schema-backed accessors.

Assisted-by: Codex:gpt-5.5
Use stable generated SQL aliases for computed select values while preserving logical output names in result shapes.

Assisted-by: Codex:gpt-5.5
@dodok8

dodok8 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex reivew

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a49ed6e80

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/sqlite-query-plan/src/lib.rs Outdated
Comment thread engine/sqlite-query-plan/src/lib.rs Outdated
Comment thread engine/query-resolver/src/lib.rs Outdated
Comment thread engine/sqlite-query-sqlgen/src/lib.rs Outdated
dodok8 added 2 commits June 19, 2026 13:48
Assign planner-owned aliases to nested path traversal joins and preserve left joins under optional nested sources.

Assisted-by: Codex:gpt-5.5
Treat computed division and modulo as nullable unless the divisor is a non-zero numeric literal.

Assisted-by: Codex:gpt-5.5
@dodok8

dodok8 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd8a2f7462

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/sqlite-query-plan/src/lib.rs Outdated
Comment thread engine/sqlite-query-plan/src/lib.rs Outdated
Reserve computed SQL aliases against selected field columns and reuse generated join aliases for repeated nested path traversals.

Assisted-by: Codex:gpt-5.5
@dodok8

dodok8 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 4a47699659

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Split resolved path lowering into focused helpers so alias, join cardinality, and scalar column handling are no longer concentrated in one function.

Assisted-by: Codex:gpt-5.5
@sonarqubecloud

Copy link
Copy Markdown

@dodok8 dodok8 merged commit 40c391d into main Jun 19, 2026
2 checks passed
@dodok8 dodok8 deleted the issue-13-computed-select-projections branch June 19, 2026 09:42
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.

feat: support computed select projections

1 participant