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:SELECT expand([1,2,3,4]) AS testresults in:
{"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.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /arcadedb, current file: none) bash-$
- Assistant
I’ll trace the SQL
expandexecution and projection alias handling, locate existing coverage, reproduce the behavior with the narrowest relevant test path, then implement and verify a general fix. First I’ll inspect repository structure and search forexpandimplementation/tests. - Assistant
ripgrepis unavailable, so I’ll use recursivegrepand constrain it to Java sources to identify the parser/executor classes and SQL tests. - Assistant
The likely flow is projection evaluation followed by
ExpandStep; the planner currently replaces anexpand(...)projection with its inner content, which may be where alias metadata is lost. I’ll inspect those classes and related tests before changing behavior. - Assistant
ProjectionItem.getExpandContent()drops the explicit alias, andExpandStephardcodes"value"only for scalar expanded items. Preserving the alias on the inner projection should make the intermediate field name available, butExpandStepmust also use that field name for scalar outputs. I’ll read the complete expand tests and projection clone/copy conventions to determine intended semantics for maps/documents versus scalars and avoid changing record expansion. - Assistant
The correct compatibility-preserving approach is:
- Preserve only an explicitly supplied
ASalias when rewritingexpand(expr)toexpr; without an alias, existing scalar output should remain"value". - Pass the intermediate projection field name into
ExpandStepfor scalar elements and use it instead of"value"when an explicit alias exists. - Continue expanding
Result,Map, and records as their own properties;ASshould name scalar values, not wrap structured results (matching existing map behavior).
I’ll inspect visibility/setters and execution-plan construction so this can be represented explicitly rather than inferred unreliably from generated expression names.
- Preserve only an explicitly supplied
- Assistant
Because the planner has a dedicated
QueryPlanningInfoobject, I’ll add anexpandAliasfield captured before rewriting and pass it toExpandStep. This avoids coupling scalar output naming to the intermediate projection’s generated default name and preserves current no-ASbehavior. The projection rewrite still needs to retain the alias so projection calculation emits the aliased intermediate field consistently. Next I’ll inspect plan serialization/copy behavior and then patch the minimal classes. - Assistant
Only
ExpandStepis instantiated here, and execution-plan caching retains the step instance/configuration, so a final alias constructor parameter is sufficient. I won’t preserve the alias on the rewritten projection because the step already accepts any single intermediate field name and explicit output naming is solely its responsibility; this keeps the change smaller and leaves structured expansion unchanged. I’ll patchQueryPlanningInfo, planner capture/constructor call, and scalar creation inExpandStep. - Assistant
Python is not installed in this environment, so no files were changed. I’ll apply the same focused edits using the repository editor command, then inspect the diff.
- Assistant
The diff review caught two line-range mistakes caused by shifting line numbers:
distinctcopying was overwritten, and theif (info.whereClause != null)guard was removed. I’ll restore both before compiling; I’ll also restore the normal blank line between constructor and annotation. - Assistant
A second line-range replacement also swallowed
syncPull’s method signature, and the earlier copy repair omittedaggregateProjection. I’ll restore those exact lines, then rely on a full compile to detect any remaining structural damage. - Assistant
The source is structurally valid now, but diff review shows
projectionAfterOrderBywas also accidentally omitted, and the intendedExpandStepcall-site update is absent (the earlier replacement did not persist). I’ll restore/update both. Maven requiresHOME, so I’ll run it withHOME=/tmpafterward. - Assistant
Compilation confirms the only constructor error is the call site. The copy diff also shows
globalLetPresentwas omitted by the last range edit, so I’ll restore it and directly edit the exact call-site line. Then I’ll compile and run the focused existing test class. - Assistant
Compile and the existing
ExpandParseTestpass. Before direct reproduction, I’ll compare the entire planning-info copy method againstHEAD; this reveals one more accidentally omitted original field (planCreated) that must be restored. Then I’ll build a temporary standalone Java reproducer outside the repository using the engine test setup/API and Maven-generated classpath, checking explicit alias, no alias compatibility, quoted alias, and structured-map behavior. - Assistant
I’ll restore
planCreated, generate the engine runtime classpath, and run the temporary reproducer. The reproducer will fail fast unless scalar aliases are honored while no-alias and map semantics remain unchanged. - Assistant
The direct reproducer passes all target and compatibility cases. Diff inspection of the copy method reveals one final original assignment (
flattenedWhereClause) was omitted by line-range editing; I’ll restore it, then ensure the final diff contains only intended additions/substitutions and rerun compile plus focused tests. - Assistant
The final diff check caught the last shifted omission:
orderBy. I’ll restore that assignment and verify the planning-info diff is now exactly two added lines. Since the compile/tests just passed and this restoration only returns original behavior, I’ll still rerun the focused test once more and inspect status/diff. - Assistant
The editor’s inclusive replacement again displaced the immediately following
limitassignment. I’ll restore it by replacing a block that includes the following assignment, then usegit diffas the definitive check: the planning-info file must show onlyexpandAliasdeclaration and copy assignment additions. - Assistant
One final adjacent assignment (
projectionsCalculated) needs restoration. I’ll replace the two-line tail with all three assignments, which intentionally increases the file by one line and should eliminate all deletions from this diff. - Assistant
The final planning-info diff is now correct and compilation passes. To avoid a source-compatibility break for any external/internal code that directly constructs the public
ExpandStep(CommandContext), I’ll retain the original constructor as an overload delegating to the new alias-aware one. Then I’ll run the focused tests and final direct reproducer against freshly compiled classes. - Assistant
The focused tests and direct reproduction pass after the compatibility overload. I’ll run the broader SQL select execution test class, which exercises neighboring projection/planner behavior, then inspect the final diff one last time before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.