From c281e9787996c70023a64ef9f55fed768462e6d6 Mon Sep 17 00:00:00 2001 From: Dery Rahman Ahaddienata Date: Mon, 30 Sep 2024 17:07:58 +0700 Subject: [PATCH] feat: add replace load method capability --- max2max/internal/loader/replace.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/max2max/internal/loader/replace.go b/max2max/internal/loader/replace.go index e7e49b3..f7bb479 100644 --- a/max2max/internal/loader/replace.go +++ b/max2max/internal/loader/replace.go @@ -1,23 +1,25 @@ package loader import ( + "fmt" "log/slog" + "strings" ) type replaceLoader struct { logger *slog.Logger } -func NewReplaceLoader(logger *slog.Logger) *replaceLoader { +func NewReplaceLoader(logger *slog.Logger) (*replaceLoader, error) { return &replaceLoader{ logger: logger, - } + }, nil } 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) }