-
Notifications
You must be signed in to change notification settings - Fork 94
GH-891: Add ExtensionTypeWriterFactory to TransferPair #892
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
base: main
Are you sure you want to change the base?
Changes from all commits
7a7e4ed
7fe36d7
8663ffc
a80b90c
3af72e7
cedb5a7
f467600
ddfca39
df38f9a
3b7cd32
5bd2e06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,7 +286,7 @@ protected void setWriter(ValueVector v) { | |
| writer = new UnionWriter((UnionVector) vector, nullableStructWriterFactory); | ||
| break; | ||
| case EXTENSIONTYPE: | ||
| writer = new UnionExtensionWriter((ExtensionTypeVector) vector); | ||
| writer = ((ExtensionType) vector.getField().getType()).getNewFieldWriter(vector); | ||
jhrotko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| break; | ||
| default: | ||
| writer = type.getNewFieldWriter(vector); | ||
|
|
@@ -325,6 +325,9 @@ protected boolean requiresArrowType(MinorType type) { | |
|
|
||
| @Override | ||
| protected FieldWriter getWriter(MinorType type, ArrowType arrowType) { | ||
| if(type == MinorType.EXTENSIONTYPE) { | ||
jhrotko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| lastExtensionType = arrowType; | ||
| } | ||
| if (state == State.UNION) { | ||
| if (requiresArrowType(type)) { | ||
| ((UnionWriter) writer).getWriter(type, arrowType); | ||
|
|
@@ -540,18 +543,25 @@ public void writeLargeVarChar(String value) { | |
| getWriter(MinorType.LARGEVARCHAR).writeLargeVarChar(value); | ||
| } | ||
|
|
||
| protected ArrowType lastExtensionType; | ||
|
|
||
| @Override | ||
| public void writeExtension(Object value) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (design) should we deprecate this method? (since we now have
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if it should be deprecated, looking at other implementations they usually offer the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe they do when there's no confusion about type/representation. But here we are relying on
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the issue with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does make for a very confusing API; there have been other issues/PRs filed about similar cases. At the very least this must detect and throw an explanatory exception for this case. Also, it would be good to have an override that lets you supply the extension type so that there's no ambiguity or potential for hard-to-diagnose runtime issues (what if a refactoring in some other part of the code eliminates the getWriter call and now your code is suddenly throwing?). Other types (like decimal) have overrides that let you supply the type, so I think this should too. |
||
| getWriter(MinorType.EXTENSIONTYPE).writeExtension(value); | ||
| FieldWriter writer = getWriter(MinorType.EXTENSIONTYPE, lastExtensionType); | ||
| if(writer instanceof UnionWriter) { | ||
| ((UnionWriter) writer).writeExtension(value, lastExtensionType); | ||
| } else { | ||
| writer.writeExtension(value); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void addExtensionTypeWriterFactory(ExtensionTypeWriterFactory factory) { | ||
| getWriter(MinorType.EXTENSIONTYPE).addExtensionTypeWriterFactory(factory); | ||
| public void writeExtension(Object value, ArrowType arrowType) { | ||
| getWriter(MinorType.EXTENSIONTYPE, arrowType).writeExtension(value); | ||
| } | ||
|
|
||
| public void addExtensionTypeWriterFactory(ExtensionTypeWriterFactory factory, ArrowType arrowType) { | ||
| getWriter(MinorType.EXTENSIONTYPE, arrowType).addExtensionTypeWriterFactory(factory); | ||
| @Override | ||
| public void write(ExtensionHolder holder) { | ||
| getWriter(MinorType.EXTENSIONTYPE, holder.type()).write(holder); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.