Java Code Examples for org.apache.arrow.vector.types.pojo.ArrowType#Timestamp

The following examples show how to use org.apache.arrow.vector.types.pojo.ArrowType#Timestamp . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
@Override
protected void doTypedSerialize(ArrowType arrowType, JsonGenerator jgen, SerializerProvider provider)
        throws IOException
{
    ArrowType.Timestamp timestamp = (ArrowType.Timestamp) arrowType;
    jgen.writeStringField(UNIT_FIELD, timestamp.getUnit().toString());
    jgen.writeStringField(TIMEZONE_FIELD, timestamp.getTimezone());
}
 
Example 2
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
@Override
protected ArrowType doTypedDeserialize(JsonParser jparser, DeserializationContext ctxt)
        throws IOException
{
    TimeUnit unit = TimeUnit.valueOf(getNextStringField(jparser, UNIT_FIELD));
    String timezone = getNextStringField(jparser, TIMEZONE_FIELD);
    return new ArrowType.Timestamp(unit, timezone);
}
 
Example 3
Source File: ArrowUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ArrowType visit(LocalZonedTimestampType localZonedTimestampType) {
	if (localZonedTimestampType.getPrecision() == 0) {
		return new ArrowType.Timestamp(TimeUnit.SECOND, null);
	} else if (localZonedTimestampType.getPrecision() >= 1 && localZonedTimestampType.getPrecision() <= 3) {
		return new ArrowType.Timestamp(TimeUnit.MILLISECOND, null);
	} else if (localZonedTimestampType.getPrecision() >= 4 && localZonedTimestampType.getPrecision() <= 6) {
		return new ArrowType.Timestamp(TimeUnit.MICROSECOND, null);
	} else {
		return new ArrowType.Timestamp(TimeUnit.NANOSECOND, null);
	}
}
 
Example 4
Source File: ArrowUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ArrowType visit(TimestampType timestampType) {
	if (timestampType.getPrecision() == 0) {
		return new ArrowType.Timestamp(TimeUnit.SECOND, null);
	} else if (timestampType.getPrecision() >= 1 && timestampType.getPrecision() <= 3) {
		return new ArrowType.Timestamp(TimeUnit.MILLISECOND, null);
	} else if (timestampType.getPrecision() >= 4 && timestampType.getPrecision() <= 6) {
		return new ArrowType.Timestamp(TimeUnit.MICROSECOND, null);
	} else {
		return new ArrowType.Timestamp(TimeUnit.NANOSECOND, null);
	}
}
 
Example 5
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
private Serializer()
{
    super(ArrowType.class, ArrowType.Timestamp.class);
}
 
Example 6
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
private Deserializer()
{
    super(ArrowType.class, ArrowType.Timestamp.class);
}
 
Example 7
Source File: APIFieldDescriber.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public Void visit(ArrowType.Timestamp timestamp) {
  return writeString(sqlTypeNameVisitor.visit(timestamp));
}
 
Example 8
Source File: SortedRangeSet.java    From aws-athena-query-federation with Apache License 2.0 2 votes vote down vote up
/**
 * Since we are mapping MinorType.TIMESTAMPMILLITZ to ArrowType.Timestamp(MILLI, ZoneId.systemDefault().getId())
 * with UTC being a place holder,
 * We cannot check the type compatibility of such types, as UTC (place holder) can be/will be overwritten by
 * the TZ value coming from the raw data.
 *
 * Comparison can still be done for such types with different TZ as we convert to data to ZonedDateType to compare.
 *
 * @param marker
 * @return if both types are ArrowType.Timestamp, returns the equality of unit
 *         else false
 */
private boolean checkTypeCompatibilityForTimeStamp(Marker marker)
{
    return getType() instanceof ArrowType.Timestamp &&
            ((ArrowType.Timestamp) getType()).getUnit().equals(((ArrowType.Timestamp) marker.getType()).getUnit());
}