wepay / kafka-connect-bigquery

DEPRECATED. PLEASE USE https://github.com/confluentinc/kafka-connect-bigquery. A Kafka Connect BigQuery sink connector
Apache License 2.0
155 stars 192 forks source link

debezium.time.Time Integer cast failure. #299

Closed subkanthi closed 3 years ago

subkanthi commented 3 years ago

The convert logic fails for SQL server time fields(HH:mm:ss) as it looks like debezium converts the value to an Integer.

`

/**

  | Get the number of milliseconds past midnight of the given {@link Duration}.   |   | @param value the duration value; may not be null   | @param acceptLargeValues whether to accept values less than 00:00:00 and larger than 24:00:00 or not   | @return the milliseconds past midnight   | @throws IllegalArgumentException if the value is not an instance of the acceptable types or it is out of the supported range   | */   | public static int toMilliOfDay(Object value, boolean acceptLargeValues) {   | if (value instanceof Duration) {   | Duration duration = (Duration) value;   | if (!acceptLargeValues && (duration.isNegative() || duration.compareTo(ONE_DAY) > 0)) {   | throw new IllegalArgumentException("Time values must be between 00:00:00 and 24:00:00 (inclusive): " + duration);   | }   |     | // int conversion is ok for the range of TIME   | return (int) ((Duration) value).toMillis();   | }   |     | // TODO only needed for SQL Server/Oracle, where we don't produce Duration right away;   | // this should go eventually, as the conversion to LocalTime is superfluous   | LocalTime time = Conversions.toLocalTime(value);   | long micros = Math.floorDiv(time.toNanoOfDay(), Conversions.NANOSECONDS_PER_MILLISECOND);   | assert Math.abs(micros) < Integer.MAX_VALUE;   | return (int) micros;   | }

`

There is an exception trying to cast to Long here. @Override public String convert(Object kafkaConnectObject) { java.util.Date date = new java.util.Date((Long) kafkaConnectObject); return getBQTimeFormat().format(date); } }