{"record":{"id":"5bef8eedf49fd957","repo":"SigNoz/signoz","slug":"error-while-fetching-logs-schema-s","errorCode":null,"errorMessage":"error while fetching logs schema: %s","messagePattern":"error while fetching logs schema: (.+?)","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":3504,"sourceCode":"\t\tv3.AggregateOperatorNoOp:\n\t\treturn &v3.AggregateAttributeResponse{}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported aggregate operator\")\n\t}\n\n\tquery = fmt.Sprintf(\"SELECT DISTINCT(tag_key), tag_type, tag_data_type from %s.%s WHERE %s and tag_type != 'logfield' limit $2\", r.logsDB, r.logsTagAttributeTableV2, where)\n\trows, err = r.db.Query(ctx, query, fmt.Sprintf(\"%%%s%%\", req.SearchText), req.Limit)\n\tif err != nil {\n\t\tr.logger.Error(\"Error while executing query\", errorsV2.Attr(err))\n\t\treturn nil, fmt.Errorf(\"error while executing query: %s\", err.Error())\n\t}\n\tdefer rows.Close()\n\n\tstatements := []model.ShowCreateTableStatement{}\n\tquery = fmt.Sprintf(\"SHOW CREATE TABLE %s.%s\", r.logsDB, r.logsLocalTableName)\n\terr = r.db.Select(ctx, &statements, query)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error while fetching logs schema: %s\", err.Error())\n\t}\n\n\tvar tagKey string\n\tvar dataType string\n\tvar attType string\n\tfor rows.Next() {\n\t\tif err := rows.Scan(&tagKey, &attType, &dataType); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error while scanning rows: %s\", err.Error())\n\t\t}\n\t\tkey := v3.AttributeKey{\n\t\t\tKey:      tagKey,\n\t\t\tDataType: v3.AttributeKeyDataType(dataType),\n\t\t\tType:     v3.AttributeKeyType(attType),\n\t\t\tIsColumn: isColumn(statements[0].Statement, attType, tagKey, dataType),\n\t\t}\n\t\tresponse.AttributeKeys = append(response.AttributeKeys, key)\n\t}\n\t// add other attributes","sourceCodeStart":3486,"sourceCodeEnd":3522,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L3486-L3522","documentation":"Error running SHOW CREATE TABLE against the logs local table while building the attribute-key response; the response uses the DDL to decide whether a tag is a real column (isColumn). Failing here aborts the whole attribute-keys result even though the key rows were fetched.","triggerScenarios":"logsLocalTableName or logsDB pointing at a non-existent table; ClickHouse user lacking SHOW/SELECT privilege on system tables; table renamed during upgrade.","commonSituations":"Config drift after renaming logs database/tables; version mismatch where query-service expects distributed_logs but deployment has different name; restricted ClickHouse user permissions.","solutions":["Verify the table exists: SHOW CREATE TABLE <logsDB>.<logsLocalTableName>","Fix logsDB/logsLocalTableName in query-service config","Grant the ClickHouse user sufficient read privileges","Align query-service version with deployed schema"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Precheck DDL access\nif _, err := db.Exec(ctx, fmt.Sprintf(\"SHOW CREATE TABLE %s.%s\", logsDB, localTable)); err != nil {\n    return fmt.Errorf(\"logs table inaccessible: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    // fall back to returning keys without isColumn info\n    return keysWithUnknownColumnFlag(rows)\n}","preventionTips":["Keep logsLocalTableName config accurate","Grant SHOW privileges to the query-service DB user"],"tags":["signoz","clickhouse","logs","schema","ddl"],"backgroundTag":"database-query-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}