Skip to content

fix: make the type transformer consistent with scalar units #107

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

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/src/main/java/io/cloudquery/scalar/Timestamp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Timestamp extends Scalar<Long> {
public static final ZoneId zoneID = ZoneOffset.UTC;

// TODO: add more units support later
private static final ArrowType dt =
public static final ArrowType dt =
new ArrowType.Timestamp(TimeUnit.MILLISECOND, zoneID.toString());

public Timestamp() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.cloudquery.transformers;

import io.cloudquery.scalar.Timestamp;
import io.cloudquery.types.InetType;
import io.cloudquery.types.JSONType;
import io.cloudquery.types.ListType;
import io.cloudquery.types.UUIDType;
import java.lang.reflect.Field;
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.TimeUnit;
import org.apache.arrow.vector.types.pojo.ArrowType;

public interface TypeTransformer {
Expand Down Expand Up @@ -41,7 +41,7 @@ private static ArrowType transformArrowType(String name, Class<?> type)
return InetType.INSTANCE;
}
case "java.time.LocalDateTime" -> {
return new ArrowType.Timestamp(TimeUnit.MICROSECOND, null);
return Timestamp.dt;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scalar base unit was changed to milliseconds, this has to be consistent.

}
case "java.util.UUID" -> {
return new UUIDType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.cloudquery.types.ListType;
import java.net.InetAddress;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Optional;
import org.apache.arrow.vector.types.FloatingPointPrecision;
Expand Down Expand Up @@ -97,7 +98,7 @@ public static final class TestClass {
Column.builder().name("any_array_col").type(JSONType.INSTANCE).build(),
Column.builder()
.name("time_col")
.type(new Timestamp(TimeUnit.MICROSECOND, null))
.type(new Timestamp(TimeUnit.MILLISECOND, ZoneOffset.UTC.getId()))
.build());

public static final List<Column> expectedColumnsSimpleClass =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.cloudquery.types.ListType;
import java.net.InetAddress;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Map;
import java.util.stream.Stream;
import org.apache.arrow.vector.types.FloatingPointPrecision;
Expand Down Expand Up @@ -102,7 +103,8 @@ public static Stream<Arguments> testArgumentsSource() {
Arguments.of("stringArrayField", ListType.listOf(ArrowType.Utf8.INSTANCE)),

// Time
Arguments.of("timeField", new ArrowType.Timestamp(TimeUnit.MICROSECOND, null)),
Arguments.of(
"timeField", new ArrowType.Timestamp(TimeUnit.MILLISECOND, ZoneOffset.UTC.getId())),

// Byte
Arguments.of("byteArrayField", ArrowType.Binary.INSTANCE),
Expand Down