|
21 | 21 | import java.util.UUID; |
22 | 22 | import org.apache.arrow.driver.jdbc.converter.AvaticaParameterConverter; |
23 | 23 | import org.apache.arrow.driver.jdbc.utils.SqlTypes; |
| 24 | +import static org.apache.arrow.driver.jdbc.utils.SqlTypes.getSqlTypeIdFromArrowType; |
| 25 | +import static org.apache.arrow.driver.jdbc.utils.SqlTypes.getSqlTypeNameFromArrowType; |
24 | 26 | import org.apache.arrow.vector.FieldVector; |
25 | 27 | import org.apache.arrow.vector.UuidVector; |
| 28 | +import org.apache.arrow.vector.extension.UuidType; |
| 29 | +import org.apache.arrow.vector.types.pojo.ExtensionTypeRegistry; |
26 | 30 | import org.apache.arrow.vector.types.pojo.Field; |
27 | 31 | import org.apache.arrow.vector.util.UuidUtility; |
28 | 32 | import org.apache.calcite.avatica.AvaticaParameter; |
@@ -82,26 +86,19 @@ public boolean bindParameter(FieldVector vector, TypedValue typedValue, int inde |
82 | 86 | @Override |
83 | 87 | public AvaticaParameter createParameter(Field field) { |
84 | 88 | final String name = field.getName(); |
85 | | - final int jdbcType = Types.OTHER; |
86 | | - final String typeName = SqlTypes.UUID_TYPE_NAME; |
| 89 | + final int jdbcType = getSqlTypeIdFromArrowType(field.getType()); |
| 90 | + final String typeName = getSqlTypeNameFromArrowType(field.getType()); |
87 | 91 | final String className = UUID.class.getCanonicalName(); |
88 | 92 | return new AvaticaParameter(false, 0, 0, jdbcType, typeName, className, name); |
89 | 93 | } |
90 | 94 |
|
91 | 95 | private static UUID uuidFromBytes(byte[] bytes) { |
92 | | -// long msb = 0; |
93 | | -// long lsb = 0; |
94 | | -// for (int i = 0; i < 8; i++) { |
95 | | -// msb = (msb << 8) | (bytes[i] & 0xff); |
96 | | -// } |
97 | | -// for (int i = 8; i < 16; i++) { |
98 | | -// lsb = (lsb << 8) | (bytes[i] & 0xff); |
99 | | -// } |
100 | | - |
101 | 96 | final long mostSignificantBits; |
102 | 97 | final long leastSignificantBits; |
103 | 98 | ByteBuffer bb = ByteBuffer.wrap(bytes); |
| 99 | + // Reads the first eight bytes |
104 | 100 | mostSignificantBits = bb.getLong(); |
| 101 | + // Reads the first eight bytes at this buffer's current |
105 | 102 | leastSignificantBits = bb.getLong(); |
106 | 103 |
|
107 | 104 | return new UUID(mostSignificantBits, leastSignificantBits); |
|
0 commit comments