Skip to content

Commit

Permalink
fix ci...
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed Jan 3, 2024
1 parent f723560 commit 7b4d963
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 37 deletions.
4 changes: 2 additions & 2 deletions csharp/test/Drivers/Interop/Snowflake/DriverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void CanGetObjectsTablesWithSpecialCharacter(string databaseName, string
.Where(s => string.Equals(s.Name, schemaName))
.Select(s => s.Tables)
.FirstOrDefault();

AdbcTable table = tables.FirstOrDefault();

Assert.True(table != null, "table should not be null");
Expand Down Expand Up @@ -409,7 +409,7 @@ private void CreateDatabaseAndTable(string databaseName, string schemaName, stri

string createDatabase = string.Format("CREATE DATABASE IF NOT EXISTS \"{0}\"", databaseName);
ExecuteUpdateStatement(createDatabase);

string createSchema = string.Format("CREATE SCHEMA IF NOT EXISTS \"{0}\".\"{1}\"", databaseName, schemaName);
ExecuteUpdateStatement(createSchema);

Expand Down
2 changes: 1 addition & 1 deletion go/adbc/driver/flightsql/flightsql_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,4 +947,4 @@ func (c *cnxn) ReadPartition(ctx context.Context, serializedPartition []byte) (r

var (
_ adbc.PostInitOptions = (*cnxn)(nil)
)
)
2 changes: 1 addition & 1 deletion go/adbc/driver/internal/shared_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,4 @@ const (
XdbcDataType_XDBC_BIT XdbcDataType = -7
XdbcDataType_XDBC_WCHAR XdbcDataType = -8
XdbcDataType_XDBC_WVARCHAR XdbcDataType = -9
)
)
6 changes: 3 additions & 3 deletions go/adbc/driver/snowflake/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func (c *cnxn) getObjectsTables(ctx context.Context, depth adbc.ObjectDepth, cat
}

func (c *cnxn) populateMetadata(ctx context.Context, depth adbc.ObjectDepth, catalog *string, dbSchema *string, tableName *string, columnName *string, tableType []string) ([]internal.Metadata, error) {
metadataRecords := make([]internal.Metadata, 0)
var metadataRecords []internal.Metadata
catalogMetadataRecords, err := c.getCatalogsMetadata(ctx)
if err != nil {
return nil, errToAdbcErr(adbc.StatusIO, err)
Expand Down Expand Up @@ -712,7 +712,7 @@ func prepareTablesSQL(matchingCatalogNames []string, catalog *string, dbSchema *
return query, queryArgs
}

func prepareColumnsSQL(matchingCatalogNames []string, catalog *string, dbSchema *string, tableName *string, columnName *string, tableType []string) (string,[]interface{}) {
func prepareColumnsSQL(matchingCatalogNames []string, catalog *string, dbSchema *string, tableName *string, columnName *string, tableType []string) (string, []interface{}) {
prefixQuery := ""
for _, catalog_name := range matchingCatalogNames {
if prefixQuery != "" {
Expand Down Expand Up @@ -1168,4 +1168,4 @@ func (c *cnxn) SetOptionDouble(key string, value float64) error {
Msg: "[Snowflake] unknown connection option",
Code: adbc.StatusNotImplemented,
}
}
}
77 changes: 47 additions & 30 deletions go/adbc/driver/snowflake/connection_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// 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 snowflake

import (
Expand Down Expand Up @@ -27,7 +44,7 @@ func TestPrepareDbSchemasSQLWithNoFilterOneCatalog(t *testing.T) {
SELECT * FROM "DEMO_DB".INFORMATION_SCHEMA.SCHEMATA
)`
actual, queryArgs := prepareDbSchemasSQL(catalogNames[:], &catalogPattern, &schemaPattern)

println("Query Args", queryArgs)
assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for DbSchemas is not being generated")
}
Expand Down Expand Up @@ -67,14 +84,14 @@ func TestPrepareDbSchemasSQLWithCatalogFilter(t *testing.T) {
SELECT * FROM "HELLO_DB".INFORMATION_SCHEMA.SCHEMATA
)
WHERE CATALOG_NAME ILIKE ? `

actual, queryArgs := prepareDbSchemasSQL(catalogNames[:], &catalogPattern, &schemaPattern)

stringqueryArgs := make([]string, len(queryArgs)) // Pre-allocate the right size
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}

assert.True(t, areStringsEquivalent(catalogPattern, strings.Join(stringqueryArgs, ",")), "The expected CATALOG_NAME is not being generated")
assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for DbSchemas is not being generated")
}
Expand All @@ -97,10 +114,10 @@ func TestPrepareDbSchemasSQLWithSchemaFilter(t *testing.T) {
actual, queryArgs := prepareDbSchemasSQL(catalogNames[:], &catalogPattern, &schemaPattern)

stringqueryArgs := make([]string, len(queryArgs)) // Pre-allocate the right size
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}

assert.True(t, areStringsEquivalent(schemaPattern, strings.Join(stringqueryArgs, ",")), "The expected SCHEMA_NAME is not being generated")
assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for DbSchemas is not being generated")
}
Expand All @@ -123,14 +140,14 @@ func TestPrepareDbSchemasSQL(t *testing.T) {
)
WHERE CATALOG_NAME ILIKE ? AND SCHEMA_NAME ILIKE ? `
actual, queryArgs := prepareDbSchemasSQL(catalogNames[:], &catalogPattern, &schemaPattern)

stringqueryArgs := make([]string, len(queryArgs)) // Pre-allocate the right size
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}

assert.True(t, areStringsEquivalent(catalogPattern+","+schemaPattern, strings.Join(stringqueryArgs, ",")), "The expected SCHEMA_NAME is not being generated")

assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for DbSchemas is not being generated")
}

Expand Down Expand Up @@ -174,12 +191,12 @@ func TestPrepareTablesSQLWithNoTableTypeFilter(t *testing.T) {
)
WHERE TABLE_CATALOG ILIKE ? AND TABLE_SCHEMA ILIKE ? AND TABLE_NAME ILIKE ? `
actual, queryArgs := prepareTablesSQL(catalogNames[:], &catalogPattern, &schemaPattern, &tableNamePattern, tableType[:])

stringqueryArgs := make([]string, len(queryArgs)) // Pre-allocate the right size
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}

assert.True(t, areStringsEquivalent(catalogPattern+","+schemaPattern+","+tableNamePattern, strings.Join(stringqueryArgs, ",")), "The expected SCHEMA_NAME is not being generated")
assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for Tables is not being generated")
}
Expand All @@ -204,10 +221,10 @@ func TestPrepareTablesSQL(t *testing.T) {
actual, queryArgs := prepareTablesSQL(catalogNames[:], &catalogPattern, &schemaPattern, &tableNamePattern, tableType[:])

stringqueryArgs := make([]string, len(queryArgs)) // Pre-allocate the right size
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}

assert.True(t, areStringsEquivalent(catalogPattern+","+schemaPattern+","+tableNamePattern, strings.Join(stringqueryArgs, ",")), "The expected SCHEMA_NAME is not being generated")
assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for Tables is not being generated")
}
Expand Down Expand Up @@ -286,10 +303,10 @@ func TestPrepareColumnsSQL(t *testing.T) {
actual, queryArgs := prepareColumnsSQL(catalogNames[:], &catalogPattern, &schemaPattern, &tableNamePattern, &columnNamePattern, tableType[:])

stringqueryArgs := make([]string, len(queryArgs)) // Pre-allocate the right size
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}
for index := range queryArgs {
stringqueryArgs[index] = fmt.Sprintf("%v", queryArgs[index])
}

assert.True(t, areStringsEquivalent(catalogPattern+","+schemaPattern+","+tableNamePattern+","+columnNamePattern, strings.Join(stringqueryArgs, ",")), "The expected SCHEMA_NAME is not being generated")
assert.True(t, areStringsEquivalent(expected, actual), "The expected SQL query for Tables is not being generated")
}
Expand All @@ -300,4 +317,4 @@ func areStringsEquivalent(str1 string, str2 string) bool {
normalizedStr2 := re.ReplaceAllString(str2, "")

return normalizedStr1 == normalizedStr2
}
}

0 comments on commit 7b4d963

Please sign in to comment.