|
1 | 1 | package com.databricks.jdbc.api.impl; |
2 | 2 |
|
3 | 3 | import com.databricks.jdbc.common.util.DatabricksTypeUtil; |
| 4 | +import com.databricks.jdbc.exception.DatabricksDriverException; |
| 5 | +import com.databricks.jdbc.exception.DatabricksSQLFeatureNotSupportedException; |
4 | 6 | import com.databricks.jdbc.log.JdbcLogger; |
5 | 7 | import com.databricks.jdbc.log.JdbcLoggerFactory; |
| 8 | +import com.databricks.jdbc.model.telemetry.enums.DatabricksDriverErrorCode; |
6 | 9 | import java.math.BigDecimal; |
7 | 10 | import java.sql.Array; |
8 | 11 | import java.sql.Date; |
@@ -77,8 +80,13 @@ private Object[] convertElements(List<Object> elements, String elementType) { |
77 | 80 | convertedElements[i] = convertValue(element, elementType); |
78 | 81 | } |
79 | 82 | } catch (Exception e) { |
80 | | - LOGGER.error("Error converting element at index {}: {}", i, e.getMessage(), e); |
81 | | - throw new IllegalArgumentException("Error converting elements", e); |
| 83 | + String errorMessage = |
| 84 | + String.format("Error converting element at index %s: %s", i, e.getMessage()); |
| 85 | + LOGGER.error(errorMessage, e); |
| 86 | + throw new DatabricksDriverException( |
| 87 | + "Error converting elements", |
| 88 | + e, |
| 89 | + DatabricksDriverErrorCode.COMPLEX_DATA_TYPE_ARRAY_CONVERSION_ERROR); |
82 | 90 | } |
83 | 91 | } |
84 | 92 | return convertedElements; |
@@ -126,9 +134,11 @@ private Object convertValue(Object value, String type) { |
126 | 134 | return value.toString(); |
127 | 135 | } |
128 | 136 | } catch (Exception e) { |
129 | | - LOGGER.error("Error converting simple value of type {}: {}", type, e.getMessage(), e); |
130 | | - throw new IllegalArgumentException( |
131 | | - "Failed to convert value " + value + " to type " + type, e); |
| 137 | + String errorMessage = |
| 138 | + String.format("Error converting simple value of type %s: %s", type, e.getMessage()); |
| 139 | + LOGGER.error(String.format("%s, value : %s", errorMessage, value), e); |
| 140 | + throw new DatabricksDriverException( |
| 141 | + errorMessage, DatabricksDriverErrorCode.COMPLEX_DATA_TYPE_ARRAY_CONVERSION_ERROR); |
132 | 142 | } |
133 | 143 | } |
134 | 144 |
|
@@ -176,27 +186,28 @@ public void free() throws SQLException { |
176 | 186 | @Override |
177 | 187 | public java.sql.ResultSet getResultSet() throws SQLException { |
178 | 188 | LOGGER.error("getResultSet() not implemented"); |
179 | | - throw new UnsupportedOperationException("getResultSet() not implemented"); |
| 189 | + throw new DatabricksSQLFeatureNotSupportedException("getResultSet() not implemented"); |
180 | 190 | } |
181 | 191 |
|
182 | 192 | @Override |
183 | 193 | public java.sql.ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException { |
184 | 194 | LOGGER.error("getResultSet(Map<String, Class<?>> map) not implemented"); |
185 | | - throw new UnsupportedOperationException( |
| 195 | + throw new DatabricksSQLFeatureNotSupportedException( |
186 | 196 | "getResultSet(Map<String, Class<?>> map) not implemented"); |
187 | 197 | } |
188 | 198 |
|
189 | 199 | @Override |
190 | 200 | public java.sql.ResultSet getResultSet(long index, int count) throws SQLException { |
191 | 201 | LOGGER.error("getResultSet(long index, int count) not implemented"); |
192 | | - throw new UnsupportedOperationException("getResultSet(long index, int count) not implemented"); |
| 202 | + throw new DatabricksSQLFeatureNotSupportedException( |
| 203 | + "getResultSet(long index, int count) not implemented"); |
193 | 204 | } |
194 | 205 |
|
195 | 206 | @Override |
196 | 207 | public java.sql.ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) |
197 | 208 | throws SQLException { |
198 | 209 | LOGGER.error("getResultSet(long index, int count, Map<String, Class<?>> map) not implemented"); |
199 | | - throw new UnsupportedOperationException( |
| 210 | + throw new DatabricksSQLFeatureNotSupportedException( |
200 | 211 | "getResultSet(long index, int count, Map<String, Class<?>> map) not implemented"); |
201 | 212 | } |
202 | 213 |
|
|
0 commit comments