stoty commented on code in PR #1571:
URL: https://github.com/apache/phoenix/pull/1571#discussion_r1143788749


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetObjectIT.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.math.BigDecimal;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.phoenix.expression.function.SqrtFunction;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * End to end tests for {@link SqrtFunction}
+ */
+@Category(ParallelStatsDisabledTest.class)
+public class GetSetObjectIT extends ParallelStatsDisabledIT {
+
+    // Temporals are tested in DateTimeIT
+    // Arrays are tested in Array1IT
+
+    @Test
+    public void testNonNumeric() throws SQLException {
+        Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
+        String tableName = generateUniqueName();
+
+        byte[] bytes = { 1, 2 };
+        String characters = "11";
+
+        try (Connection conn = DriverManager.getConnection(getUrl(), props);
+                Statement stmt = conn.createStatement();
+                PreparedStatement insertStmt =
+                        conn.prepareStatement("upsert into " + tableName
+                                + "(id, binary_col, varbinary_col, 
boolean_col, char_col, varchar_col) values (?,?,?,?,?,?)")) {
+            stmt.executeUpdate("CREATE TABLE " + tableName
+                    + " (ID INTEGER PRIMARY KEY, BINARY_COL BINARY(2), 
VARBINARY_COL VARBINARY, BOOLEAN_COL BOOLEAN, CHAR_COL CHAR(2), VARCHAR_COL 
VARCHAR)");
+            insertStmt.setInt(1, 1);
+            // The type specific setters also delegate to these
+            insertStmt.setObject(2, bytes);
+            insertStmt.setObject(3, bytes);
+            insertStmt.setObject(4, Boolean.TRUE);
+            insertStmt.setObject(5, characters);
+            insertStmt.setObject(6, characters);
+            insertStmt.executeUpdate();
+            conn.commit();
+
+            ResultSet rs = stmt.executeQuery("select * from " + tableName);
+            while (rs.next()) {
+                assertArrayEquals(bytes, rs.getBytes(2));
+                assertArrayEquals(bytes, (byte[]) rs.getObject(2));
+                assertArrayEquals(bytes, rs.getObject(2, byte[].class));
+                try {
+                    rs.getObject(2, Long.class);
+                    fail("We only implement byte[]");
+                } catch (SQLException e) {

Review Comment:
   Makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to