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 first inspect the SQL execution and tests for
expand, then reproduce the alias behavior with the narrowest existing test suite. After identifying where the expanded result property name is assigned, I’ll implement a general alias-preserving fix and run focused plus relevant broader tests. - Assistant
ripgrepis unavailable, so I’ll use recursivegrepto locate the SQL function implementation, projection execution, and existing expand tests. - Assistant
The likely flow is projection calculation followed by
ExpandStep. I’ll inspect both, the projection item’s alias API, and focused tests to determine whether aliases are lost at planning time or overwritten only for scalar expanded values. - Assistant
ExpandStepdiscovers the sole projected property name (propName) but hardcodes"value"when an expanded item is scalar. Before changing that directly, I need to verify what property name projection calculation produces when no explicit alias is supplied, because existing unaliased behavior may intentionally remain"value". - Assistant
The parser exposes the explicit alias, but
getExpandContent()currently drops it while replacingexpand(expr)withexpr. That means simply usingpropNameinExpandStepmay not work unless planning preserves the alias. I’ll inspect projection rewriting andcalculateSingleto trace the exact intermediate name. - Assistant
The correct compatibility-preserving design is to carry only an explicit alias into
ExpandStep: scalar values use that alias, while unaliased scalar expansion keeps the established"value"name. Expanded maps/documents/results should remain flattened and not be wrapped, consistent withexpandsemantics. I’ll check constructor conventions and repository status, then implement this by preserving the alias during projection rewrite and passing it to the expansion step. - Assistant
The working tree is clean and only the planner constructs
ExpandStep, so a backward-compatible constructor overload is straightforward. I’ll now preserve the explicit alias inProjectionItem.getExpandContent(), pass it from the rewritten projection intoExpandStep, and use it only for scalar output. - Assistant
Python is not installed in the environment, so no files were changed. I’ll apply the same three small edits with the repository’s non-interactive
replacehelper, then inspect the diff. - Assistant
The editor helper applies multiline replacements only within its current displayed window; therefore the constructor edit succeeded, while the two off-window edits did not. I’ll use line-targeted
editoperations at the reported locations and then verify all changed code. - Assistant
The line ranges included each method’s closing brace, and my replacement omitted it; the diff correctly exposes that syntax error. I’ll restore both method braces immediately, then compile before attempting behavioral verification.
- Assistant
The syntax is now corrected. Maven’s wrapper requires
HOME, which this sandbox leaves unset; I’ll set it explicitly and run the engine compile plus the focusedExpandStepTest. - Assistant
Compilation and all existing
ExpandStepTestcases pass. To verify the exact reported query without adding or modifying repository tests, I’ll build a temporary standalone Java check under/tmp, using the engine’s test runtime classpath. It will assert both the aliased result (test) and backward-compatible unaliased result (value). - Assistant
The local database API supports creating a temporary database directly. I’ll compile and run the standalone assertion, deleting its database directory afterward so the repository remains untouched.
- Assistant
The fixed build returns exactly
test: 1..4, while an unaliased expansion still returnsvalue. To satisfy the reproduction checklist rigorously, I’ll temporarily stash the source changes, rebuild the original revision, and run a minimal printer for the reported query to confirm it yields[value]; then I’ll restore the changes and rebuild. No repository test files will be touched. - Assistant
The original revision reproduced the issue exactly (
[value]=1through[value]=4despiteAS test), and the fix has been restored and recompiled successfully. I’ll now run the focused parser/projection/expand tests together, inspect formatting and the final diff, and ensure there are no generated or temporary files.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.