From d5d18947ae20b71be5e15e15ce1b1b1a093d0715 Mon Sep 17 00:00:00 2001 From: Dery Rahman Ahaddienata Date: Fri, 11 Oct 2024 14:30:27 +0700 Subject: [PATCH] feat: merge and replace load method --- max2max/internal/loader/merge.go | 8 ++++---- max2max/internal/loader/replace.go | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/max2max/internal/loader/merge.go b/max2max/internal/loader/merge.go index f9ef4bb..f4a3e08 100644 --- a/max2max/internal/loader/merge.go +++ b/max2max/internal/loader/merge.go @@ -14,10 +14,10 @@ func NewMergeLoader(logger *slog.Logger) *mergeLoader { } } -func (l *mergeLoader) GetQuery(tableID, query string) string { - return "-- TODO merge loader" +func (l *mergeLoader) GetQuery(_, query string) string { + return query } -func (l *mergeLoader) GetPartitionedQuery(tableID, query string, partitionName []string) string { - return "-- TODO merge loader" +func (l *mergeLoader) GetPartitionedQuery(_, query string, _ []string) string { + return query } diff --git a/max2max/internal/loader/replace.go b/max2max/internal/loader/replace.go index e7e49b3..b2a1fe2 100644 --- a/max2max/internal/loader/replace.go +++ b/max2max/internal/loader/replace.go @@ -1,7 +1,9 @@ package loader import ( + "fmt" "log/slog" + "strings" ) type replaceLoader struct { @@ -15,9 +17,9 @@ func NewReplaceLoader(logger *slog.Logger) *replaceLoader { } func (l *replaceLoader) GetQuery(tableID, query string) string { - return "-- TODO replace loader" + return fmt.Sprintf("INSERT OVERWRITE TABLE %s %s", tableID, query) } -func (l *replaceLoader) GetPartitionedQuery(tableID, query string, partitionName []string) string { - return "-- TODO replace loader" +func (l *replaceLoader) GetPartitionedQuery(tableID, query string, partitionNames []string) string { + return fmt.Sprintf("INSERT OVERWRITE TABLE %s PARTITION (%s) %s", tableID, strings.Join(partitionNames, ", "), query) }