ISSUE DESCRIPTION [SQL] "expand" projection is always named "value" ignoring "AS"…
- User
ISSUE DESCRIPTION
[SQL] "expand" projection is always named "value" ignoring "AS"
ArcadeDB Server v26.5.1 (build b6d08fee549dd5930303b362223869901aab0fac/1778533954349/main)Running on Linux 6.17.0-29-generic - OpenJDK 64-Bit Server VM 25.0.3-eaUsing
expandin a projection, the result-set contains an property namedvalueinspite an alias of the formAS x:sqlSELECT expand([1,2,3,4]) AS testresults in:
json{"result":[{"value":1},{"value":2},{"value":3},{"value":4}]}ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
- Assistant
I’ll locate the SQL projection/
expandimplementation and its tests, reproduce the current alias behavior with the narrowest existing test harness, then patch the result naming logic and run focused plus relevant broader tests. - Assistant
The SQL executor has a dedicated
ExpandStep, while parsing already preserves projection aliases. I’ll inspect how the planner passes projection metadata into that step and how scalar versus document values are converted into result rows. - Assistant
ExpandStepcurrently hardcodes"value"only when an expanded item is scalar. Its input row already has exactly one property, whose name should be the explicit alias aftergetExpandContent(). The safest fix may therefore be to retain that input property name for scalar output, without renaming expanded documents/maps (whose own fields are intentionally flattened). I’ll verify alias propagation and existing expand test expectations before editing. - Assistant
A key detail is that
ProjectionItem.getExpandContent()currently drops the alias, so merely using the input property name would both fail to recoverAS testand change unaliased behavior to an expression-shaped key. I’ll traceQueryPlanningInfoinitialization so the explicit alias can be passed toExpandStepwhile preserving the established"value"fallback when noASis present. - Assistant
The original projection is still available from the planner’s
statement, but a cleaner design is to preserve the alias ingetExpandContent()and letExpandStepuse the sole projected property name only when an explicit alias exists. Since preserving the alias makes the projected property name reliable, the step can receive a nullable alias determined before projection rewriting. I’ll inspect planner ordering and constructors/copy conventions to implement this without affecting cached plans or directExpandSteptests. - Assistant
Planner ordering confirms
optimizeQuery()detectsexpandand has access to the explicitProjectionItem.aliasimmediately before replacing the projection. I’ll store that nullable alias inQueryPlanningInfo, propagate it throughcopy(), and pass it toExpandStep. Scalar rows will use the alias when present and retain"value"otherwise; expandedResult, record, and map rows will remain flattened exactly as before. - Assistant
I’ll now make the focused three-file change: planning metadata, alias capture/passing, and scalar result naming. The fallback remains unchanged, and the alias string comes from the parsed identifier so quoted aliases are handled consistently.
- Assistant
Python is unavailable in this environment, so no files were changed. I’ll apply the same exact substitutions with Perl and immediately inspect the diff.
- Assistant
The diff is minimal and preserves all non-scalar expansion semantics. I’ll compile and run the focused
ExpandStepTestandExpandParseTestsuites first. After that, I’ll execute the reported SQL through an existing runtime entry point or a temporary out-of-repository harness to verify exact property names and values, including the no-alias fallback and map expansion edge case. - Assistant
The Maven wrapper requires
HOME, which this sandbox does not set; compilation did not start. I’ll rerun withHOME=/tmp, leaving repository configuration untouched. - Assistant
Compilation and both focused suites pass. To verify the exact reported behavior without modifying tests, I’ll create a temporary Java harness under
/tmp, use ArcadeDB’s public embedded database API, run the aliased scalar query, the same query without an alias, and an aliased map expansion, then print each row’s property names/value. The harness will not become part of the repository. - Assistant
The temporary runtime verification now produces
{test=1}through{test=4}, retains{value=...}for unaliased scalar expansion, and retains flattened{x, y}fields for aliased map expansion as required by existing behavior. I’ll run the broader SQL execution tests most likely to exercise planner copying/caching and projection pipelines, then review the final diff/status for accidental files. - Assistant
The broader planner/parser/expand-related suites pass, and only the intended three source files are modified. To satisfy the reproduction checklist rigorously (rather than relying only on the observed hardcoded pre-fix code), I’ll temporarily save the patch, restore the original files, compile and run the same
/tmpharness to capture the original{value=...}behavior, then reapply the patch and rerun compilation plus the harness once more.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.