{"record":{"id":"84611507daaaccc7","repo":"PRQL/prql","slug":"expected-a-table-or-query-found-an-empty-tuple","errorCode":null,"errorMessage":"expected a table or query, found an empty tuple `{}`","messagePattern":"expected a table or query, found an empty tuple `(.+?)`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/semantic/resolver/functions.rs","lineNumber":280,"sourceCode":"                log::debug!(\"resolved arg to {}\", arg.kind.as_ref());\n\n                resolved_relations.push((index, arg, is_last));\n            }\n\n            // Then, add relation frames into scope\n            for (index, arg, is_last) in resolved_relations {\n                if partial_application_position.is_none() {\n                    let frame = arg.lineage.as_ref().ok_or_else(|| {\n                        // Provide helpful error for empty arrays/tuples used directly\n                        // (not from functions like std.from_text which set lineage properly)\n                        match &arg.kind {\n                            ExprKind::Array(v) if v.is_empty() => Error::new(Reason::Expected {\n                                who: None,\n                                expected: \"a table or query\".to_string(),\n                                found: \"an empty array `[]`\".to_string(),\n                            })\n                            .with_span(arg.span),\n                            ExprKind::Tuple(v) if v.is_empty() => Error::new(Reason::Expected {\n                                who: None,\n                                expected: \"a table or query\".to_string(),\n                                found: \"an empty tuple `{}`\".to_string(),\n                            })\n                            .with_span(arg.span),\n                            _ => Error::new_bug(4317).with_span(closure.body.span),\n                        }\n                    })?;\n                    if is_last {\n                        self.root_mod.module.insert_frame(frame, NS_THIS);\n                    } else {\n                        self.root_mod.module.insert_frame(frame, NS_THAT);\n                    }\n                }\n\n                closure.args[index] = arg;\n            }\n        }","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/semantic/resolver/functions.rs#L262-L298","documentation":"Same validation as the empty-array case: when a relation argument is a bare empty tuple `{}` it has no lineage and cannot act as a table, so the resolver throws this specific error instead of bug #4317 (which is reserved for other lineage-less arguments).","triggerScenarios":"`from {}` or passing an empty tuple literal `{}` to a function/transform expecting a table or query.","commonSituations":"Misusing tuple literals as data sources, or an intermediate variable that ended up an empty tuple being fed to `from`/`join`.","solutions":["Replace the empty tuple with a real relation (`from table` or `from_text ...`)","Check the upstream expression producing the tuple — it is likely losing its columns","Remove the empty tuple argument if it was accidental"],"exampleFix":"// before\nfrom {}\n// after\nfrom employees","handlingStrategy":"validation","validationCode":"function validateRelationArg(arg) {\n  if (arg && typeof arg === \"object\" && !Array.isArray(arg) && Object.keys(arg).length === 0) {\n    throw new Error(\"empty tuple {} is not a table; use from_text or a real table\");\n  }\n}","typeGuard":"function isEmptyTupleLiteral(expr) {\n  return expr && expr.kind === \"tuple\" && expr.items.length === 0;\n}","tryCatchPattern":"try {\n  compile(query);\n} catch (e) {\n  if (e.message.includes(\"an empty tuple\")) {\n    console.error(\"Tuple literals are not relations; source from a table or from_text.\");\n  } else { throw e; }\n}","preventionTips":["Never pass {} as a pipeline source","Trace intermediate variables that may collapse to empty tuples","Use from/join only with tables, views, or from_text output"],"tags":["prql","resolver","empty-tuple"],"backgroundTag":"empty-required-field","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}