Skip to content

Commit 9017582

Browse files
authored
fix: set table type to external for glue (#6386)
# Description - Set table type as external for Glue tables ## Linear Ticket - Resolves WAR-1177 ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Ensure AWS Glue tables are created and updated as EXTERNAL_TABLE, with tests asserting the table type. > > - **Glue schema repository**: > - Set `TableType` to `EXTERNAL_TABLE` in `CreateTable` and `updateTable`. > - **Tests**: > - Assert created table `TableType` is `EXTERNAL_TABLE`. > - Add missing `require.NoError` after `AddColumns`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e00eb99. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 502d2b0 commit 9017582

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

warehouse/integrations/datalake/schema-repository/glue.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/rudderlabs/rudder-go-kit/logger"
1717
"github.com/rudderlabs/rudder-go-kit/stats"
1818
obskit "github.com/rudderlabs/rudder-observability-kit/go/labels"
19+
1920
utils "github.com/rudderlabs/rudder-server/utils/awsutils"
2021
"github.com/rudderlabs/rudder-server/warehouse/internal/model"
2122
"github.com/rudderlabs/rudder-server/warehouse/logfield"
@@ -93,6 +94,7 @@ func (g *GlueSchemaRepository) CreateTable(ctx context.Context, tableName string
9394
tableInput := &types.TableInput{
9495
Name: aws.String(tableName),
9596
PartitionKeys: partitionKeys,
97+
TableType: aws.String("EXTERNAL_TABLE"),
9698
}
9799

98100
// create table request
@@ -271,7 +273,8 @@ func (g *GlueSchemaRepository) updateTable(ctx context.Context, tableName string
271273
glueInput := &glue.UpdateTableInput{
272274
DatabaseName: aws.String(g.Namespace),
273275
TableInput: &types.TableInput{
274-
Name: aws.String(tableName),
276+
Name: aws.String(tableName),
277+
TableType: aws.String("EXTERNAL_TABLE"),
275278
},
276279
}
277280

warehouse/integrations/datalake/schema-repository/glue_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ func TestGlueSchemaRepositoryRoundTrip(t *testing.T) {
142142
err = g.CreateTable(ctx, testTable, testColumns)
143143
require.NoError(t, err)
144144

145+
tableOutput, err := g.GlueClient.GetTable(ctx, &glue.GetTableInput{
146+
Name: &testTable,
147+
DatabaseName: &testNamespace,
148+
})
149+
require.NoError(t, err)
150+
require.NotNil(t, tableOutput.Table)
151+
require.Equal(t, "EXTERNAL_TABLE", *tableOutput.Table.TableType)
152+
145153
t.Log("Creating already existing table should not fail")
146154
err = g.CreateTable(ctx, testTable, testColumns)
147155
require.NoError(t, err)
@@ -154,6 +162,7 @@ func TestGlueSchemaRepositoryRoundTrip(t *testing.T) {
154162
{Name: "alter_test_float", Type: "float"},
155163
{Name: "alter_test_datetime", Type: "datetime"},
156164
})
165+
require.NoError(t, err)
157166

158167
t.Log("Preparing load files metadata")
159168
f, err := os.Open(testFile)

0 commit comments

Comments
 (0)