Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mc2mc/pkg/query/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (b *Builder) constructOverridedValues(query string) (string, error) {
// constructMergeQueries constructs merge queries with headers and variables
func (b *Builder) constructMergeQuery(hrs, vars, queries []string) string {
// for dry run purposes, multiquery generation will still be generated
if !b.enableDryRun && b.disableMultiQueryGeneration {
if !b.enableDryRun && (b.disableMultiQueryGeneration || len(queries) <= 1) {
if b.costAttributionTeam != "" {
return fmt.Sprintf("%s\n%s", b.query, getCostAttributionComment(b.costAttributionTeam))
}
Expand Down
14 changes: 2 additions & 12 deletions mc2mc/pkg/query/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func TestBuilder_Build(t *testing.T) {
query.WithMethod(query.MERGE),
).Build()
assert.NoError(t, err)
assert.Equal(t, `select * from project.playground.table
;`, query)
assert.Equal(t, queryToExecute, query)
})
t.Run("returns error for append load method when destination table is not specify", func(t *testing.T) {
queryToExecute := `select * from project.playground.table;`
Expand Down Expand Up @@ -547,16 +546,7 @@ SET append_test.id = 2;`
query.WithMethod(query.MERGE),
).Build()
assert.NoError(t, err)
assert.Equal(t, `SET odps.table.append2.enable=true
;
@src := SELECT 1 id
;
MERGE INTO append_test
USING (SELECT * FROM @src) source
on append_test.id = source.id
WHEN MATCHED THEN UPDATE
SET append_test.id = 2
;`, query)
assert.Equal(t, queryToExecute, query)
})
t.Run("returns query for merge load method with drop and create table", func(t *testing.T) {
queryToExecute := `SET odps.table.append2.enable=true;
Expand Down
Loading