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
11 changes: 9 additions & 2 deletions cmd/next-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func main() {
return
}

// Sort by explain_todo count (fewest first), then by query size
// Sort by explain_todo count (most first), then by query size
sort.Slice(todoTests, func(i, j int) bool {
if todoTests[i].explainTodoLen != todoTests[j].explainTodoLen {
return todoTests[i].explainTodoLen < todoTests[j].explainTodoLen
return todoTests[i].explainTodoLen > todoTests[j].explainTodoLen
}
return todoTests[i].querySize < todoTests[j].querySize
})
Expand Down Expand Up @@ -116,5 +116,12 @@ func main() {
}
}

// Calculate total pending statements across all tests
totalStatements := 0
for _, t := range todoTests {
totalStatements += t.explainTodoLen
}

fmt.Printf("\nRemaining explain_todo tests: %d\n", len(todoTests))
fmt.Printf("Total pending statements: %d\n", totalStatements)
}
8 changes: 2 additions & 6 deletions internal/explain/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,8 @@ func explainAliasedExpr(sb *strings.Builder, n *ast.AliasedExpr, depth int) {
Node(sb, e.Then, depth+2)
Node(sb, e.Else, depth+2)
case *ast.CastExpr:
// CAST expressions - show alias only for CAST(x AS Type) syntax, not CAST(x, 'Type')
if e.UsedASSyntax {
explainCastExprWithAlias(sb, e, n.Alias, indent, depth)
} else {
explainCastExpr(sb, e, indent, depth)
}
// CAST expressions always show the alias from the AliasedExpr wrapper
explainCastExprWithAlias(sb, e, n.Alias, indent, depth)
case *ast.ArrayAccess:
// Array access - show alias only when array is not a literal
// ClickHouse hides alias when array access is on a literal
Expand Down
11 changes: 6 additions & 5 deletions internal/explain/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ func FormatFloat(val float64) string {
if math.IsNaN(val) {
return "nan"
}
// Use scientific notation for very small numbers (< 1e-6)
// This matches ClickHouse's behavior where numbers like 0.0000001 (-1e-7)
// are displayed in scientific notation
// Use scientific notation for very small numbers (< 1e-6) or very large numbers (>= 1e21)
// This matches ClickHouse's behavior
absVal := math.Abs(val)
if absVal > 0 && absVal < 1e-6 {
if (absVal > 0 && absVal < 1e-6) || absVal >= 1e21 {
s := strconv.FormatFloat(val, 'e', -1, 64)
// Remove leading zeros from exponent (e-07 -> e-7)
// Remove leading zeros from exponent (e-07 -> e-7, e+07 -> e+7)
s = strings.Replace(s, "e-0", "e-", 1)
s = strings.Replace(s, "e+0", "e+", 1)
// Remove the + from positive exponents (e+21 -> e21)
s = strings.Replace(s, "e+", "e", 1)
return s
}
// Use decimal notation for normal-sized numbers
Expand Down
7 changes: 1 addition & 6 deletions parser/testdata/00541_kahan_sum/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt3": true,
"stmt4": true
}
}
{}
7 changes: 1 addition & 6 deletions parser/testdata/00700_decimal_casts/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt121": true,
"stmt122": true
}
}
{}
9 changes: 1 addition & 8 deletions parser/testdata/00700_decimal_casts_2/metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{
"explain_todo": {
"stmt86": true,
"stmt89": true,
"stmt92": true,
"stmt95": true
}
}
{}
8 changes: 1 addition & 7 deletions parser/testdata/00700_decimal_math/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
{
"explain_todo": {
"stmt17": true,
"stmt27": true,
"stmt7": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01013_hex_float/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt5": true
}
}
{}
8 changes: 1 addition & 7 deletions parser/testdata/01262_low_cardinality_remove/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
{
"explain_todo": {
"stmt11": true,
"stmt6": true,
"stmt9": true
}
}
{}
2 changes: 1 addition & 1 deletion parser/testdata/01322_cast_keep_nullable/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt11":true,"stmt12":true,"stmt7":true,"stmt8":true}}
{}
7 changes: 1 addition & 6 deletions parser/testdata/01323_if_with_nulls/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt10": true,
"stmt16": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01442_date_time_with_params/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt6": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt3":true,"stmt4":true}}
{}
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt13": true,
"stmt16": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01458_named_tuple_millin/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt6": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01499_json_named_tuples/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt1": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt3":true,"stmt4":true,"stmt5":true}}
{}
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{
"explain_todo": {
"stmt1": true,
"stmt2": true,
"stmt4": true,
"stmt5": true
}
}
{}
11 changes: 1 addition & 10 deletions parser/testdata/01521_format_readable_time_delta2/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
{
"explain_todo": {
"stmt15": true,
"stmt16": true,
"stmt17": true,
"stmt18": true,
"stmt19": true,
"stmt20": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01536_fuzz_cast/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt2": true
}
}
{}
2 changes: 1 addition & 1 deletion parser/testdata/01550_create_map_type/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt37":true,"stmt48":true}}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01605_key_condition_enum_int/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt2": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01651_group_uniq_array_enum/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt3": true
}
}
{}
6 changes: 1 addition & 5 deletions parser/testdata/01670_neighbor_lc_bug/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt3": true
}
}
{}
8 changes: 1 addition & 7 deletions parser/testdata/01744_tuple_cast_to_map_bugfix/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
{
"explain_todo": {
"stmt1": true,
"stmt2": true,
"stmt3": true
}
}
{}
7 changes: 1 addition & 6 deletions parser/testdata/01804_uniq_up_to_ubsan/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt1": true,
"stmt2": true
}
}
{}
8 changes: 1 addition & 7 deletions parser/testdata/01822_short_circuit/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
{
"explain_todo": {
"stmt114": true,
"stmt115": true,
"stmt116": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{
"explain_todo": {
"stmt1": true,
"stmt2": true,
"stmt3": true,
"stmt4": true
}
}
{}
2 changes: 1 addition & 1 deletion parser/testdata/02036_jit_short_circuit/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt7":true}}
{}
6 changes: 1 addition & 5 deletions parser/testdata/02042_map_get_non_const_key/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt1": true
}
}
{}
7 changes: 1 addition & 6 deletions parser/testdata/02126_lc_window_functions/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt3": true,
"stmt4": true
}
}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"stmt23": true,
"stmt26": true,
"stmt29": true,
"stmt3": true,
"stmt30": true,
"stmt32": true,
"stmt35": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"explain_todo": {
"stmt11": true,
"stmt2": true,
"stmt4": true,
"stmt5": true,
"stmt9": true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt1": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt2":true,"stmt4":true}}
{}
11 changes: 1 addition & 10 deletions parser/testdata/02475_precise_decimal_arithmetics/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
{
"explain_todo": {
"stmt10": true,
"stmt11": true,
"stmt5": true,
"stmt6": true,
"stmt7": true,
"stmt8": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"explain_todo": {
"stmt12": true,
"stmt23": true,
"stmt24": true,
"stmt25": true,
"stmt26": true,
"stmt27": true,
"stmt28": true,
"stmt29": true,
"stmt30": true,
"stmt31": true,
"stmt32": true,
"stmt4": true,
"stmt8": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt7": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"explain_todo": {
"stmt10": true,
"stmt12": true,
"stmt14": true,
"stmt16": true,
"stmt18": true,
"stmt20": true,
"stmt22": true,
"stmt24": true,
"stmt8": true
"stmt24": true
}
}
2 changes: 1 addition & 1 deletion parser/testdata/02542_transform_new/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"explain_todo":{"stmt35":true,"stmt37":true}}
{}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt6": true
}
}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"stmt14": true,
"stmt16": true,
"stmt2": true,
"stmt20": true,
"stmt9": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"stmt19": true,
"stmt2": true,
"stmt21": true,
"stmt25": true,
"stmt9": true
}
}
7 changes: 1 addition & 6 deletions parser/testdata/02715_bit_operations_float/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"explain_todo": {
"stmt1": true,
"stmt2": true
}
}
{}
8 changes: 1 addition & 7 deletions parser/testdata/02715_or_null/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
{
"explain_todo": {
"stmt1": true,
"stmt2": true,
"stmt3": true
}
}
{}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"explain_todo": {
"stmt2": true
}
}
{}
Loading