When using .NET to connect to AWS Redshift Serverless, tables I created cannot be seen

80 views Asked by At

I am using .NET 6.0 with Visual Studio + AWS Explorer plugin that has my credential saved. I created a simple table consisting of first name and last name.

create table name(
firstname varchar(200),
lastnamename varchar(200)
);

Then insert 2 data points:

INSERT INTO name VALUES ('jacky', 'chen'), ('elon', 'musk')

I see the names show up when I query them.

  • The workgroup is preview.
  • The database is dev.
  • The schema is public.
  • The table name is name.

enter image description here

Here is the .NET code I am using to access it:

using Amazon.RedshiftDataAPIService;
using Amazon.RedshiftDataAPIService.Model;
using Amazon.Runtime.Internal;

var client = new AmazonRedshiftDataAPIServiceClient(region: Amazon.RegionEndpoint.USEast1);

ListDatabasesRequest listDatabase = new ListDatabasesRequest();
listDatabase.WorkgroupName = "preview";
listDatabase.Database = "dev";
var temp = client.ListDatabasesAsync(listDatabase);
Task.WaitAll(temp);


ListSchemasRequest listSchemas = new ListSchemasRequest();
listSchemas.WorkgroupName = "preview";
listSchemas.Database = "dev";
var temp3 = client.ListSchemasAsync(listSchemas);
Task.WaitAll(temp3);

ListTablesRequest listTables = new ListTablesRequest();
listTables.WorkgroupName = "preview";
listTables.Database = "dev";
listTables.SchemaPattern = "%public";
var temp2 = client.ListTablesAsync(listTables);
foreach (var table in temp2.Result.Tables)
{
    if (table.Name == "name")
    {
        Console.WriteLine("found");
    }
}

Task.WaitAll(temp2);

Console.ReadLine();

temp and temp3 variables does see my database (dev) and schema (public). However, temp2 result has nothing.

enter image description here

Can anyone help me figure out why my manually created table will not be seen from my code? However, the same code can see the tables from sample_data_dev workgroup provided by Amazon as a Redshift example.

I tried creating another table inside sample_data_dev/tickit example and loaded it with same names data points. It had 7 tables to begin with. After I created another table, I have 8 total. When I run my code, I only see the original 7 tables. It seems anything I created manually cannot be seen from my .NET code. Very baffled. Any help would be nice.

0

There are 0 answers