@@ -6821,7 +6821,10 @@ func (p *Parser) parseSystem() *ast.SystemQuery {
68216821 strings .HasSuffix (upperCmd , " MOVES" ) ||
68226822 strings .HasSuffix (upperCmd , " FETCHES" ) ||
68236823 strings .HasSuffix (upperCmd , " SENDS" ) ||
6824- strings .HasSuffix (upperCmd , " MUTATIONS" ) {
6824+ strings .HasSuffix (upperCmd , " MUTATIONS" ) ||
6825+ upperCmd == "FLUSH DISTRIBUTED" ||
6826+ upperCmd == "STOP DISTRIBUTED SENDS" ||
6827+ upperCmd == "START DISTRIBUTED SENDS" {
68256828 // Next token should be the table name
68266829 break
68276830 }
@@ -6901,13 +6904,13 @@ func (p *Parser) parseSystem() *ast.SystemQuery {
69016904 }
69026905 } else {
69036906 // For certain commands, the table name appears as both database and table in EXPLAIN
6907+ // But for FLUSH DISTRIBUTED, use DuplicateTableOutput instead of setting both
69046908 upperCmd := strings .ToUpper (sys .Command )
69056909 if strings .Contains (upperCmd , "RELOAD DICTIONARY" ) ||
69066910 strings .Contains (upperCmd , "DROP REPLICA" ) ||
69076911 strings .Contains (upperCmd , "RESTORE REPLICA" ) ||
69086912 strings .Contains (upperCmd , "STOP DISTRIBUTED SENDS" ) ||
6909- strings .Contains (upperCmd , "START DISTRIBUTED SENDS" ) ||
6910- strings .Contains (upperCmd , "FLUSH DISTRIBUTED" ) {
6913+ strings .Contains (upperCmd , "START DISTRIBUTED SENDS" ) {
69116914 sys .Database = tableName
69126915 sys .Table = tableName
69136916 } else {
@@ -6917,11 +6920,14 @@ func (p *Parser) parseSystem() *ast.SystemQuery {
69176920 }
69186921
69196922 // Set DuplicateTableOutput for commands that need database/table output twice
6920- // Only duplicate when we have a qualified name (database != table)
69216923 upperCmd := strings .ToUpper (sys .Command )
6922- if strings .Contains (upperCmd , "STOP DISTRIBUTED SENDS" ) ||
6924+ if strings .Contains (upperCmd , "FLUSH DISTRIBUTED" ) {
6925+ // FLUSH DISTRIBUTED always outputs the table name twice (even if unqualified)
6926+ if sys .Table != "" {
6927+ sys .DuplicateTableOutput = true
6928+ }
6929+ } else if strings .Contains (upperCmd , "STOP DISTRIBUTED SENDS" ) ||
69236930 strings .Contains (upperCmd , "START DISTRIBUTED SENDS" ) ||
6924- strings .Contains (upperCmd , "FLUSH DISTRIBUTED" ) ||
69256931 strings .Contains (upperCmd , "RELOAD DICTIONARY" ) {
69266932 // Only set duplicate if database and table are different (qualified name)
69276933 if sys .Database != sys .Table {
0 commit comments