Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(csharp/test/Drivers/Interop/Snowflake): Updated the metadata tests to work without the db name #1352

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions csharp/test/Drivers/Interop/Snowflake/DriverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ public DriverTests()
Dictionary<string, string> options = new Dictionary<string, string>();
_snowflakeDriver = SnowflakeTestingUtils.GetSnowflakeAdbcDriver(_testConfiguration, out parameters);

string databaseName = _testConfiguration.Metadata.Catalog;
string schemaName = _testConfiguration.Metadata.Schema;

parameters[SnowflakeParameters.DATABASE] = databaseName;
parameters[SnowflakeParameters.SCHEMA] = schemaName;

_database = _snowflakeDriver.Open(parameters);
_connection = _database.Connect(options);
}
Expand Down Expand Up @@ -212,7 +206,7 @@ public void CanGetObjectsTables(string tableNamePattern)
string tableName = _testConfiguration.Metadata.Table;

using IArrowArrayStream stream = _connection.GetObjects(
depth: AdbcConnection.GetObjectsDepth.All,
depth: AdbcConnection.GetObjectsDepth.Tables,
catalogPattern: databaseName,
dbSchemaPattern: schemaName,
tableNamePattern: tableNamePattern,
Expand All @@ -233,6 +227,7 @@ public void CanGetObjectsTables(string tableNamePattern)

AdbcTable table = tables.Where((table) => string.Equals(table.Name, tableName)).FirstOrDefault();
Assert.True(table != null, "table should not be null");
Assert.Equal("BASE TABLE", table.Type);
}

/// <summary>
Expand All @@ -258,18 +253,21 @@ public void CanGetObjectsAll()
using RecordBatch recordBatch = stream.ReadNextRecordBatchAsync().Result;

List<AdbcCatalog> catalogs = GetObjectsParser.ParseCatalog(recordBatch, databaseName, schemaName);

List<AdbcColumn> columns = catalogs
AdbcTable table = catalogs
.Where(c => string.Equals(c.Name, databaseName))
.Select(c => c.DbSchemas)
.FirstOrDefault()
.Where(s => string.Equals(s.Name, schemaName))
.Select(s => s.Tables)
.FirstOrDefault()
.Where(t => string.Equals(t.Name, tableName))
.Select(t => t.Columns)
.FirstOrDefault();


Assert.True(table != null, "table should not be null");
Assert.Equal("BASE TABLE", table.Type);
List<AdbcColumn> columns = table.Columns;

Assert.True(columns != null, "Columns cannot be null");
Assert.Equal(_testConfiguration.Metadata.ExpectedColumnCount, columns.Count);

Expand Down
Loading