ryan-syed commented on code in PR #1467:
URL: https://github.com/apache/arrow-adbc/pull/1467#discussion_r1454025738


##########
csharp/test/Drivers/Interop/Snowflake/CastTests.cs:
##########
@@ -0,0 +1,397 @@
+/*
+* 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.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Apache.Arrow.Ipc;
+using Apache.Arrow.Types;
+using Xunit;
+
+namespace Apache.Arrow.Adbc.Tests.Drivers.Interop.Snowflake
+{
+    // TODO: When supported, use prepared statements instead of SQL string 
literals
+    //      Which will better test how the driver handles values sent/received
+
+    public class CastTests : IDisposable
+    {
+        private const string COLUMN_NAME = "SOURCE_COLUMN";
+        static readonly string s_testTablePrefix = "ADBCCASTTEST_"; // Make 
configurable? Also; must be all caps if not double quoted
+        readonly SnowflakeTestConfiguration _snowflakeTestConfiguration;
+        readonly AdbcConnection _connection;
+        readonly AdbcStatement _statement;
+        readonly string _catalogSchema;
+        readonly Dictionary<string, string> _columnSpecifications;
+        private bool _disposed = false;
+
+        /// <summary>
+        /// Validates that specific conversion and casting functions perform 
correctly.
+        /// Note: Does not test the generic CAST and TRY_CAST, but instead 
uses the
+        /// direct conversion functions.
+        /// </summary>
+        public CastTests()
+        {
+            
Skip.IfNot(Utils.CanExecuteTestConfig(SnowflakeTestingUtils.SNOWFLAKE_TEST_CONFIG_VARIABLE));
+            _snowflakeTestConfiguration = 
SnowflakeTestingUtils.TestConfiguration;
+            Dictionary<string, string> parameters = new Dictionary<string, 
string>();
+            Dictionary<string, string> options = new Dictionary<string, 
string>();
+            AdbcDriver snowflakeDriver = 
SnowflakeTestingUtils.GetSnowflakeAdbcDriver(_snowflakeTestConfiguration, out 
parameters);
+            AdbcDatabase adbcDatabase = snowflakeDriver.Open(parameters);
+            _connection = adbcDatabase.Connect(options);
+            _statement = _connection.CreateStatement();
+            _catalogSchema = string.Format("{0}.{1}", 
_snowflakeTestConfiguration.Metadata.Catalog, 
_snowflakeTestConfiguration.Metadata.Schema);
+            // Simplify TIMEZONE tests so we don't have to deal with time zone 
offsets.
+            SetSessionTimezone(_statement, "UTC");
+        }
+
+        [SkippableTheory]
+        // From NUMERIC
+        [InlineData("BIGINT", "2345", "2345", ArrowTypeId.String, 
"TO_VARCHAR")]
+        [InlineData("INTEGER", "2345", "2345", ArrowTypeId.String, 
"TO_VARCHAR")]
+        [InlineData("NUMERIC(1,0)", "-9", "-09.00", ArrowTypeId.String, 
"TO_VARCHAR", COLUMN_NAME + ", '00.00'")]
+        [InlineData("NUMERIC(1,0)", "9", "09.00 ", ArrowTypeId.String, 
"TO_VARCHAR", COLUMN_NAME + ", '00.00MI'")]
+        [InlineData("NUMERIC(38,2)", "9.50", 9.5, ArrowTypeId.Double, 
"TO_DOUBLE")]
+        [InlineData("NUMERIC(1,0)", "1", true, ArrowTypeId.Boolean, 
"TO_BOOLEAN")]
+        [InlineData("NUMERIC(1,0)", "0", false, ArrowTypeId.Boolean, 
"TO_BOOLEAN")]
+        // From DOUBLE
+        [InlineData("DOUBLE", "2345.67", "2345.67", ArrowTypeId.String, 
"TO_VARCHAR")]
+        [InlineData("DOUBLE", "2345.67", 2345.67, ArrowTypeId.Double, 
"TO_DOUBLE")]
+        [InlineData("DOUBLE", "2345.5", 2346, ArrowTypeId.Decimal128, 
"TO_NUMERIC")] // Rounded up
+        [InlineData("DOUBLE", "2345.4", 2345, ArrowTypeId.Decimal128, 
"TO_NUMERIC")] // Rounded down
+        [InlineData("DOUBLE", "2345.67", 2345.67, ArrowTypeId.Decimal128, 
"TO_NUMERIC", COLUMN_NAME + ", 6, 2")]
+        // From BOOLEAN
+        [InlineData("BOOLEAN", "'true'", "true", ArrowTypeId.String, 
"TO_VARCHAR")]
+        [InlineData("BOOLEAN", "'false'", "false", ArrowTypeId.String, 
"TO_VARCHAR")]
+        // From VARCHAR
+        [InlineData("VARCHAR", "'欢迎'", "欢迎", ArrowTypeId.String, "TO_VARCHAR")]

Review Comment:
   nit: we could use constant strings for the cast functions 



-- 
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