{"record":{"id":"3d74b12f32e1487b","repo":"wtfutil/wtf","slug":"query-returned-table-with-no-columns-s","errorCode":null,"errorMessage":"query returned table with no columns: %s","messagePattern":"query returned table with no columns: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/azurelogs/query.go","lineNumber":88,"sourceCode":"\t\tqf.WorkspaceID,\n\t\tazquery.Body{\n\t\t\tQuery: to.Ptr(qf.Query),\n\t\t},\n\t\tnil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to execute query on workspace %s: %w\", qf.WorkspaceID, err)\n\t}\n\n\tif res.Error != nil {\n\t\treturn nil, res.Error\n\t}\n\n\tswitch len(res.Tables) {\n\tcase 0:\n\t\treturn nil, fmt.Errorf(\"query returned no data tables: %s\", qf.Query)\n\tcase 1:\n\t\tif len(res.Tables[0].Columns) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"query returned table with no columns: %s\", qf.Query)\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"query returned %d tables, expected 1: %s\", len(res.Tables), qf.Query)\n\t}\n\n\t// Process each row of data\n\tfor _, row := range res.Tables[0].Rows {\n\t\tvar r TableRow\n\n\t\tfor _, field := range row {\n\t\t\tif field == nil {\n\t\t\t\tr = append(r, \"\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Convert all data types to string representation\n\t\t\tswitch v := field.(type) {\n\t\t\tcase string:","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/azurelogs/query.go#L70-L106","documentation":"RunQuery throws this when the single returned table has a Columns slice of length zero. Column metadata is required to map each row's values to output fields, so a column-less table cannot be processed. The KQL query text is included in the message for debugging.","triggerScenarios":"RunQuery or fetchDataAsync receiving a response with exactly one table but zero columns — usually an API-side anomaly or a degenerate query (e.g. a query returning an empty projection like `| project` with no columns, or certain scalar-only queries).","commonSituations":"Malformed KQL projection clauses, queries against custom tables with broken schemas, or proxy/gateway responses that strip the table schema.","solutions":["Review the KQL projection: ensure `| project` lists at least one column and columns are named","Re-run the query in the Azure Portal editor to confirm it returns a proper schema","Check for schema issues on custom tables (run ` TableName | getschema`)","If a proxy is in front of the API, verify it is not truncating the response body"],"exampleFix":"// before\nMyTable | project  // no columns listed\n// after\nMyTable | project TimeGenerated, OperationName, ResultSignature","handlingStrategy":"validation","validationCode":"// ensure the query defines explicit named columns\nif !strings.Contains(strings.ToLower(qf.Query), \"project \") && !strings.Contains(strings.ToLower(qf.Query), \"extend \") {\n    return errors.New(\"query should use | project with named columns\")\n}","typeGuard":null,"tryCatchPattern":"tables, err := RunQuery(sess)\nif err != nil {\n    if strings.Contains(err.Error(), \"no columns\") {\n        return fmt.Errorf(\"KQL returns no schema; fix projection: %w\", err)\n    }\n    return err\n}","preventionTips":["Always end queries with an explicit `| project col1, col2`","Run `TableName | getschema` to confirm the table schema","Validate KQL in the portal editor before adding to query files"],"tags":["azure","log-analytics","kql","schema"],"backgroundTag":"empty-query-result","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}