Skip to content

Commit

Permalink
Merge pull request #109 from OHDSI/drop-chunk-fix
Browse files Browse the repository at this point in the history
Update DbSource.cs
  • Loading branch information
bradanton authored Aug 15, 2024
2 parents 412a59e + 6a6c4b9 commit 4d38d9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void CreateChunkSchema(string name)
}
}

private string GetQuery(string name)
private string GetQuery(string name, string schema)
{
string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
var resource = resourceNames.First(a => a.EndsWith(name) && a.Contains(_dbType, StringComparison.OrdinalIgnoreCase));
Expand All @@ -39,7 +39,7 @@ private string GetQuery(string name)
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
using var reader = new StreamReader(stream, Encoding.Default);
var query = reader.ReadToEnd();
query = query.Replace("{sc}", schemaName);
query = query.Replace("{sc}", schema);

return query;
}
Expand All @@ -49,7 +49,10 @@ public void CreateChunkTable(string schemaName)
CreateChunkSchema(schemaName);
DropChunkTable(schemaName);

var query = GetQuery("CreateChunkTable.sql");
var query = GetQuery("CreateChunkTable.sql", schemaName);

Console.WriteLine("CreateChunkTable:" + query);

using var connection = SqlConnectionHelper.OpenOdbcConnection(_connectionString);
using var cmd = new OdbcCommand(query, connection);
cmd.ExecuteNonQuery();
Expand All @@ -59,8 +62,9 @@ public void DropChunkTable(string schemaName)
{
CreateChunkSchema(schemaName);

var query = GetQuery("DropChunkTable.sql");
var query = GetQuery("DropChunkTable.sql", schemaName);

Console.WriteLine("DropChunkTable:" + query);
using var connection = SqlConnectionHelper.OpenOdbcConnection(_connectionString);
using var cmd = new OdbcCommand(query, connection);
cmd.ExecuteNonQuery();
Expand All @@ -80,7 +84,7 @@ public IEnumerable<long> GetPersonIds(int chunkId, string schemaName)

public void CreateIndexesChunkTable(string schemaName)
{
var query = GetQuery("CreateIndexesChunkTable.sql");
var query = GetQuery("CreateIndexesChunkTable.sql", schemaName);

if (string.IsNullOrEmpty(query.Trim()))
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ static int Main(string[] arguments)
var sourceReleaseDate = dbSource.GetSourceReleaseDate();
var vocabularyVersion = DbBuildingSettings.GetVocabularyVersion(vocabularyConnectionString, vocabularySchema);

Console.WriteLine("SourceReleaseDate:" + sourceReleaseDate);
Console.WriteLine("VocabularyVersion:" + vocabularyVersion);

if (Settings.Current.Building.Cdm == CdmVersions.V54)
{
var reader = new CdmSourceDataReader54(DateTime.Parse(sourceReleaseDate), vocabularyVersion);
Expand Down

0 comments on commit 4d38d9e

Please sign in to comment.