|
19 | 19 | import java.sql.ResultSet; |
20 | 20 | import java.sql.ResultSetMetaData; |
21 | 21 | import java.sql.SQLException; |
| 22 | +import java.sql.Types; |
22 | 23 | import java.util.HashSet; |
23 | 24 | import java.util.List; |
24 | 25 | import java.util.Objects; |
|
28 | 29 | import org.apache.arrow.util.AutoCloseables; |
29 | 30 | import org.apache.arrow.vector.VectorSchemaRoot; |
30 | 31 | import org.apache.arrow.vector.types.pojo.Schema; |
| 32 | +import org.apache.calcite.avatica.AvaticaConnection; |
31 | 33 | import org.apache.calcite.avatica.AvaticaResultSet; |
32 | 34 | import org.apache.calcite.avatica.AvaticaResultSetMetaData; |
| 35 | +import org.apache.calcite.avatica.AvaticaSite; |
33 | 36 | import org.apache.calcite.avatica.AvaticaStatement; |
34 | 37 | import org.apache.calcite.avatica.ColumnMetaData; |
35 | 38 | import org.apache.calcite.avatica.Meta; |
36 | 39 | import org.apache.calcite.avatica.Meta.Frame; |
37 | 40 | import org.apache.calcite.avatica.Meta.Signature; |
38 | 41 | import org.apache.calcite.avatica.QueryState; |
| 42 | +import org.apache.calcite.avatica.util.Cursor; |
39 | 43 | import org.slf4j.Logger; |
40 | 44 | import org.slf4j.LoggerFactory; |
41 | 45 |
|
@@ -102,6 +106,33 @@ void populateData(final VectorSchemaRoot vectorSchemaRoot, final Schema schema) |
102 | 106 | execute2(new ArrowFlightJdbcCursor(vectorSchemaRoot), this.signature.columns); |
103 | 107 | } |
104 | 108 |
|
| 109 | + /** |
| 110 | + * The default method in AvaticaResultSet does not properly handle TIMESTASMP_WITH_TIMEZONE, so we |
| 111 | + * override here to add support. |
| 112 | + * |
| 113 | + * @param columnIndex the first column is 1, the second is 2, ... |
| 114 | + * @return |
| 115 | + * @throws SQLException |
| 116 | + */ |
| 117 | + @Override |
| 118 | + public Object getObject(int columnIndex) throws SQLException { |
| 119 | + this.checkOpen(); |
| 120 | + |
| 121 | + Cursor.Accessor accessor; |
| 122 | + try { |
| 123 | + accessor = accessorList.get(columnIndex - 1); |
| 124 | + } catch (IndexOutOfBoundsException var3) { |
| 125 | + throw AvaticaConnection.HELPER.createException("invalid column ordinal: " + columnIndex); |
| 126 | + } |
| 127 | + |
| 128 | + ColumnMetaData metaData = columnMetaDataList.get(columnIndex - 1); |
| 129 | + if (metaData.type.id == Types.TIMESTAMP_WITH_TIMEZONE) { |
| 130 | + return accessor.getTimestamp(localCalendar); |
| 131 | + } else { |
| 132 | + return AvaticaSite.get(accessor, metaData.type.id, localCalendar); |
| 133 | + } |
| 134 | + } |
| 135 | + |
105 | 136 | @Override |
106 | 137 | protected void cancel() { |
107 | 138 | signature.columns.clear(); |
|
0 commit comments