Skip to content

Commit

Permalink
[fix](trino-connector) Fix the problem of reading the DATE type fro…
Browse files Browse the repository at this point in the history
…m Trino too slowly (#37266)

Previously, we use
`LocalDate.parse(DateTimeUtils.printDate(block.getInt(position, 0)),
DateTimeFormatter.ISO_DATE)` to handle DATE type from Trino.

Now, we use `LocalDate.ofEpochDay(block.getInt(position, 0))` to handle
DATE type from Trino.
This will result in a 20-fold speed improvement.
  • Loading branch information
BePPPower authored and dataroaring committed Jul 17, 2024
1 parent 686b9db commit 418e732
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
import io.trino.spi.type.SqlTimestampWithTimeZone;
import io.trino.spi.type.TimeType;
import io.trino.spi.type.Type;
import io.trino.util.DateTimeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

public class TrinoConnectorColumnValue implements ColumnValue {
Expand Down Expand Up @@ -155,7 +153,7 @@ public byte[] getStringAsBytes() {
// block is IntArrayBlock
@Override
public LocalDate getDate() {
return LocalDate.parse(DateTimeUtils.printDate(block.getInt(position, 0)), DateTimeFormatter.ISO_DATE);
return LocalDate.ofEpochDay(block.getInt(position, 0));
}

// block is LongArrayBlock
Expand Down

0 comments on commit 418e732

Please sign in to comment.