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

[arrow] Read timestamp vector and process by paimon self #4008

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@
import org.apache.arrow.vector.IntVector;
import org.apache.arrow.vector.SmallIntVector;
import org.apache.arrow.vector.TimeMilliVector;
import org.apache.arrow.vector.TimeStampVector;
import org.apache.arrow.vector.TinyIntVector;
import org.apache.arrow.vector.VarBinaryVector;
import org.apache.arrow.vector.VarCharVector;
import org.apache.arrow.vector.complex.ListVector;
import org.apache.arrow.vector.complex.MapVector;
import org.apache.arrow.vector.complex.StructVector;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -375,8 +374,17 @@ public boolean isNullAt(int index) {

@Override
public Timestamp getTimestamp(int i, int precision) {
return Timestamp.fromLocalDateTime(
(LocalDateTime) (vector.getObject(i)));
long value = ((TimeStampVector) vector).get(i);
if (precision == 0) {
return Timestamp.fromEpochMillis(value * 1000);
} else if (precision >= 1 && precision <= 3) {
return Timestamp.fromEpochMillis(value);
} else if (precision >= 4 && precision <= 6) {
return Timestamp.fromMicros(value);
} else {
return Timestamp.fromEpochMillis(
value / 1_000_000, (int) value % 1_000_000);
}
}
};
}
Expand Down Expand Up @@ -463,13 +471,13 @@ public Arrow2PaimonVectorConverter visit(MapType mapType) {
new MapColumnVector() {

private boolean inited = false;
private MapVector mapVector;
private ListVector mapVector;
private ColumnVector keyColumnVector;
private ColumnVector valueColumnVector;

private void init() {
if (!inited) {
this.mapVector = (MapVector) vector;
this.mapVector = (ListVector) vector;
StructVector listVector = (StructVector) mapVector.getDataVector();

FieldVector keyVector = listVector.getChildrenFromFields().get(0);
Expand Down
Loading