Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getNewFieldWriter returns UnionListWriter instead of UnionMapWriter #625

Open
wsuppiger opened this issue Feb 20, 2025 · 1 comment · May be fixed by #627
Open

getNewFieldWriter returns UnionListWriter instead of UnionMapWriter #625

wsuppiger opened this issue Feb 20, 2025 · 1 comment · May be fixed by #627
Labels
help wanted Extra attention is needed Type: bug Something isn't working

Comments

@wsuppiger
Copy link

wsuppiger commented Feb 20, 2025

Not sure if I am using this wrong, but I noticed getNewFieldWriter for the minorType MAP is returning a UnionListWriter instead of a UnionMapWriter.

@Override
public FieldWriter getNewFieldWriter(ValueVector vector) {
return new UnionListWriter((MapVector) vector);
}
},

This leads to the issue of this code block throwing an error:

writer = MinorType.MAP.getNewFieldWriter(myMapVector)
writer.startMap()

Exception:

You tried to start a map key when you are using a ValueWriter of type UnionListWriter.
java.lang.IllegalStateException: You tried to start a map key when you are using a ValueWriter of type UnionListWriter.
	at org.apache.arrow.vector.complex.impl.AbstractFieldWriter.key(AbstractFieldWriter.java:123)
	at org.apache.arrow.vector.complex.impl.UnionListWriter.key(UnionListWriter.java:69)
...

I believe this code can be easily fixed by just changing it to:

   @Override 
   public FieldWriter getNewFieldWriter(ValueVector vector) { 
     return new UnionMapWriter((MapVector) vector); 
   } 
@lidavidm lidavidm added Type: bug Something isn't working help wanted Extra attention is needed labels Feb 20, 2025
@lidavidm
Copy link
Member

PRs would be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants