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}]}Interface
No new interfaces are introduced.
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
Let me explore the repository structure to understand the codebase and find relevant files for the SQL "expand" projection issue.
Assistant
Now I see the issue. In the
fetchNextmethod, when the value being expanded is a plain object (not a Result, Identifiable, Map, etc.), the code creates aResultInternaland sets the property to "value":javanextElement = new ResultInternal(context.getDatabase()); ((ResultInternal) nextElement).setProperty("value", nextElementObj);The alias from
AS testis not being respected. Let me understand how the alias is passed. Let me search for where the ExpandStep is created and how the alias is handled.Assistant
Let me look at how the projection and alias info is structured.
Assistant
Now I need to understand the projection and alias. The projection in
SELECT expand([1,2,3,4]) AS testis an expressionexpand(...)with an aliastest. Let me look at how the projection is parsed and how the alias is stored.Let me look at the Projection class.
Assistant
Let me look at how the planner handles expand and projection to understand the flow.
Assistant
Let me look at lines around 690-710 where the expand projection is handled.
Assistant
Let me reproduce the issue first. Let me look for how tests run queries.
Assistant
Let me write a reproduction test based on the existing test structure.
Assistant
The bug is confirmed. Now let me search for existing tests that rely on the "value" property from expand, to make sure my fix doesn't break them.
Assistant
Let me look at the existing expand tests that may use simple values.
Assistant
These tests expand documents/records, not plain values, so they go through the Identifiable/Result branches, not the plain "value" branch. Good.
Now let me check the UnwindExpandStepTest which sets "value" property on a document.
Assistant
Let me look at the main plan method to understand the order of operations.
Assistant
Let me check all usages of
ExpandStepconstructor across the codebase.Assistant
Let me check all usages of
getExpandContent.Assistant
Now let me implement the fix. First, let me modify
ProjectionItem.getExpandContent()to preserve the alias.Assistant
Now let me modify the
ExpandStepto accept and use the alias.Assistant
Let me check the
AbstractExecutionStepfor copy/serialization methods that may need updating.Assistant
Let me check if
ExecutionStepInternalrequires acopymethod.Assistant
Let me check how cached plans handle step reset, to ensure the alias field doesn't cause issues.
Assistant
ExpandStep doesn't override
canBeCached(defaults to false), so plans with ExpandStep are not cached. The alias field is safe. Now let me implement the changes to ExpandStep.Assistant
Now let me update the plain-value branch to use the alias.
Assistant
Now let me update the planner's
handleExpandto pass the alias.Assistant
I need to navigate to that line first. Let me open the file at the right location.
Assistant
Let me verify the
Identifierimport exists in the planner.Assistant
Good,
Identifieris imported. Now let me re-run my reproduction test.Assistant
The fix works. With alias "test", the property is now "test"; without alias, it remains "value" (backward compatible).
Let me test some edge cases - expand of strings, expand with nested projection + alias, and expand of a list of records with alias.
Assistant
All tests passed. Let me confirm explicitly with the test summary.
Assistant
All 5 tests pass. Now let me run the existing expand-related tests to ensure I didn't break anything.
Assistant
Now let me run the broader select execution tests to ensure nothing broke.
Assistant
Let me run a broader set of SQL/projection tests to be thorough.
Assistant
Let me check whether there are any tests that verify projection serialization/toString that could be affected by preserving the alias in getExpandContent.
Assistant
Let me verify the vector tests that reference expand aren't using an alias in a way that would change behavior.
Assistant
Let me search the broader repository (server, integration, etc.) for any tests expecting the "value" property from expand with an alias, to ensure no regression elsewhere.
Assistant
Let me check if any test checks the
ExpandStepprettyPrint output, before deciding whether to enhance it.Assistant
No test checks the SQL ExpandStep prettyPrint string. Let me enhance the prettyPrint to include the alias for clarity in EXPLAIN output.
Assistant
Now let me re-run all the relevant tests once more to confirm everything passes with the prettyPrint enhancement.
Assistant
All 262 tests pass. Let me verify the full engine module compiles cleanly (the changes touch 3 files).
Assistant
Let me check for any other references to ExpandStep across the entire codebase (e.g., distributed/serialization).
Assistant
The fix is complete and verified. Now let me remove the temporary reproduction test file, as the instructions prohibit adding new tests to the repository.
Assistant
Let me review the final diff to confirm the changes are clean and correct.
Assistant
The diff is clean and minimal. Let me run a couple more relevant test classes (GroupBy and graph expand) to be thorough.
Assistant
All tests pass. Let me do a final verification of the exact issue scenario with a quick inline query test to confirm the JSON-like output matches the expected behavior, then submit.
Assistant
Let me see why it failed - re-run with more detail.
Assistant
A compilation error in my temporary test (ambiguous
append). Let me fix it.Assistant
Let me simplify the test to avoid StringBuilder ambiguity issues.
Assistant
The exact issue scenario is confirmed fixed:
SELECT expand([1,2,3,4]) AS testnow produces keys "test" with values 1,2,3,4. Let me remove the temporary test file.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.