Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Feb 10, 2025
1 parent 0ee9910 commit 25be9a6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clients/iceberg/dialect/dialect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dialect

import (
"fmt"
"strings"

"github.com/artie-labs/transfer/lib/sql"
)

type IcebergDialect struct{}

func (IcebergDialect) GetDefaultValueStrategy() sql.DefaultValueStrategy {
return sql.Native
}

func (IcebergDialect) QuoteIdentifier(identifier string) string {
return fmt.Sprintf("`%s`", strings.ReplaceAll(identifier, "`", ""))
}
39 changes: 39 additions & 0 deletions clients/iceberg/dialect/tableid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dialect

import (
"fmt"

"github.com/artie-labs/transfer/lib/sql"
)

var _dialect = IcebergDialect{}

type TableIdentifier struct {
catalog string
namespace string
table string
}

func NewTableIdentifier(catalog, namespace, table string) TableIdentifier {
return TableIdentifier{catalog: catalog, namespace: namespace, table: table}
}

func (ti TableIdentifier) Namespace() string {
return ti.namespace
}

func (ti TableIdentifier) EscapedTable() string {
return _dialect.QuoteIdentifier(ti.table)
}

func (ti TableIdentifier) Table() string {
return ti.table
}

func (ti TableIdentifier) WithTable(table string) sql.TableIdentifier {
return NewTableIdentifier(ti.catalog, ti.namespace, table)
}

func (ti TableIdentifier) FullyQualifiedName() string {
return fmt.Sprintf("%s.%s.%s", _dialect.QuoteIdentifier(ti.catalog), _dialect.QuoteIdentifier(ti.namespace), ti.EscapedTable())
}

0 comments on commit 25be9a6

Please sign in to comment.