You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "davidhcoe (via GitHub)" <gi...@apache.org> on 2023/11/13 18:17:42 UTC

[PR] feat(csharp/tests): Add support for data without need for tables [arrow-adbc]

davidhcoe opened a new pull request, #1287:
URL: https://github.com/apache/arrow-adbc/pull/1287

   - Add support for dynamic data that can execute against data sources without physical tables
   - Add data for tests of issues previously found in BigQuery and Snowflake
   - Refactor common functionality into the Apache.Arrow.Adbc.Tests project from the respective drivers
   
   Addresses https://github.com/apache/arrow-adbc/pull/1282#issuecomment-1806034942


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(csharp/test): Add support for data without need for tables [arrow-adbc]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher merged PR #1287:
URL: https://github.com/apache/arrow-adbc/pull/1287


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(csharp/tests): Add support for data without need for tables [arrow-adbc]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on code in PR #1287:
URL: https://github.com/apache/arrow-adbc/pull/1287#discussion_r1391545100


##########
csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs:
##########
@@ -31,6 +33,143 @@ namespace Apache.Arrow.Adbc.Tests
     /// </summary>
     public class ClientTests
     {
+        /// <summary>
+        /// Validates if the client execute updates.
+        /// </summary>
+        /// <param name="adbcConnection">The <see cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see cref="TestConfiguration"/> to use</param>
+        /// <param name="queries">The queries to run</param>
+        /// <param name="expectedResults">The expected results (one per query)</param>
+        public static void CanClientExecuteUpdate(Adbc.Client.AdbcConnection adbcConnection,
+            TestConfiguration testConfiguration,
+            string[] queries,
+            List<int> expectedResults)
+        {
+            if (adbcConnection == null) throw new ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new ArgumentNullException(nameof(testConfiguration));
+            if (queries == null) throw new ArgumentNullException(nameof(queries));
+            if (expectedResults == null) throw new ArgumentNullException(nameof(expectedResults));
+            if (queries.Length != expectedResults.Count) throw new ArgumentException($"{nameof(queries)} and {nameof(expectedResults)} must have the same number of values");
+
+            adbcConnection.Open();
+
+            for (int i = 0; i < queries.Length; i++)
+            {
+                string query = queries[i];
+                AdbcCommand adbcCommand = adbcConnection.CreateCommand();
+                adbcCommand.CommandText = query;
+
+                int rows = adbcCommand.ExecuteNonQuery();
+
+                Assert.Equal(expectedResults[i], rows);
+            }
+        }
+
+        /// <summary>
+        /// Validates if the client can get the schema.
+        /// </summary>
+        /// <param name="adbcConnection">The <see cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see cref="TestConfiguration"/> to use</param>
+        public static void CanClientGetSchema(Adbc.Client.AdbcConnection adbcConnection, TestConfiguration testConfiguration)
+        {
+            if (adbcConnection == null) throw new ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new ArgumentNullException(nameof(testConfiguration));
+
+            AdbcCommand adbcCommand = new AdbcCommand(testConfiguration.Query, adbcConnection);
+
+            adbcConnection.Open();
+
+            AdbcDataReader reader = adbcCommand.ExecuteReader(CommandBehavior.SchemaOnly);
+
+            DataTable table = reader.GetSchemaTable();
+
+            // there is one row per field
+            Assert.Equal(testConfiguration.Metadata.ExpectedColumnCount, table.Rows.Count);
+        }
+
+        /// <summary>
+        /// Validates if the client can connect to a live server and
+        /// parse the results.
+        /// </summary>
+        /// <param name="adbcConnection">The <see cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see cref="TestConfiguration"/> to use</param>
+        public static void CanClientExecuteQuery(Adbc.Client.AdbcConnection adbcConnection, TestConfiguration testConfiguration)
+        {
+            if (adbcConnection == null) throw new ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new ArgumentNullException(nameof(testConfiguration));
+
+            long count = 0;
+
+            AdbcCommand adbcCommand = new AdbcCommand(testConfiguration.Query, adbcConnection);

Review Comment:
   DbCommand is IDisposable; would be good to "using" it.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(csharp/tests): Add support for data without need for tables [arrow-adbc]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on code in PR #1287:
URL: https://github.com/apache/arrow-adbc/pull/1287#discussion_r1391537414


##########
csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs:
##########
@@ -31,6 +33,143 @@ namespace Apache.Arrow.Adbc.Tests
     /// </summary>
     public class ClientTests
     {
+        /// <summary>
+        /// Validates if the client execute updates.
+        /// </summary>
+        /// <param name="adbcConnection">The <see cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see cref="TestConfiguration"/> to use</param>
+        /// <param name="queries">The queries to run</param>
+        /// <param name="expectedResults">The expected results (one per query)</param>
+        public static void CanClientExecuteUpdate(Adbc.Client.AdbcConnection adbcConnection,
+            TestConfiguration testConfiguration,
+            string[] queries,
+            List<int> expectedResults)
+        {
+            if (adbcConnection == null) throw new ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new ArgumentNullException(nameof(testConfiguration));
+            if (queries == null) throw new ArgumentNullException(nameof(queries));
+            if (expectedResults == null) throw new ArgumentNullException(nameof(expectedResults));
+            if (queries.Length != expectedResults.Count) throw new ArgumentException($"{nameof(queries)} and {nameof(expectedResults)} must have the same number of values");
+
+            adbcConnection.Open();
+
+            for (int i = 0; i < queries.Length; i++)
+            {
+                string query = queries[i];
+                AdbcCommand adbcCommand = adbcConnection.CreateCommand();
+                adbcCommand.CommandText = query;
+
+                int rows = adbcCommand.ExecuteNonQuery();
+
+                Assert.Equal(expectedResults[i], rows);
+            }
+        }
+
+        /// <summary>
+        /// Validates if the client can get the schema.
+        /// </summary>
+        /// <param name="adbcConnection">The <see cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see cref="TestConfiguration"/> to use</param>
+        public static void CanClientGetSchema(Adbc.Client.AdbcConnection adbcConnection, TestConfiguration testConfiguration)
+        {
+            if (adbcConnection == null) throw new ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new ArgumentNullException(nameof(testConfiguration));
+
+            AdbcCommand adbcCommand = new AdbcCommand(testConfiguration.Query, adbcConnection);
+
+            adbcConnection.Open();
+
+            AdbcDataReader reader = adbcCommand.ExecuteReader(CommandBehavior.SchemaOnly);
+
+            DataTable table = reader.GetSchemaTable();
+
+            // there is one row per field
+            Assert.Equal(testConfiguration.Metadata.ExpectedColumnCount, table.Rows.Count);
+        }
+
+        /// <summary>
+        /// Validates if the client can connect to a live server and
+        /// parse the results.
+        /// </summary>
+        /// <param name="adbcConnection">The <see cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see cref="TestConfiguration"/> to use</param>
+        public static void CanClientExecuteQuery(Adbc.Client.AdbcConnection adbcConnection, TestConfiguration testConfiguration)
+        {
+            if (adbcConnection == null) throw new ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new ArgumentNullException(nameof(testConfiguration));
+
+            long count = 0;
+
+            AdbcCommand adbcCommand = new AdbcCommand(testConfiguration.Query, adbcConnection);
+
+            adbcConnection.Open();
+
+            AdbcDataReader reader = adbcCommand.ExecuteReader();
+
+            try
+            {
+                while (reader.Read())
+                {
+                    count++;
+
+                    for (int i = 0; i < reader.FieldCount; i++)
+                    {
+                        object value = reader.GetValue(i);
+
+                        if (value == null)
+                            value = "(null)";
+
+                        // write out the values to ensure things like null are correctly returned
+                        Console.WriteLine($"{reader.GetName(i)}: {value}");
+                    }
+                }
+            }
+            finally { reader.Close(); }

Review Comment:
   Why not "using"? 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(csharp/tests): Add support for data without need for tables [arrow-adbc]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1287:
URL: https://github.com/apache/arrow-adbc/pull/1287#issuecomment-1808742931

   :warning: Please follow the [Conventional Commits format in CONTRIBUTING.md](https://github.com/apache/arrow-adbc/blob/main/CONTRIBUTING.md) for PR titles.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org