{"record":{"id":"a7a78394387a9ce1","repo":"dgraph-io/dgraph","slug":"facets-are-not-supported-in-the-rdf-output-format","errorCode":null,"errorMessage":"facets are not supported in the rdf output format","messagePattern":"facets are not supported in the rdf output format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/outputrdf.go","lineNumber":232,"sourceCode":"func validateSubGraphForRDF(sg *SubGraph) error {\n\tif sg.IsGroupBy() {\n\t\treturn errors.New(\"groupby is not supported in rdf output format\")\n\t}\n\tuidCount := sg.Attr == \"uid\" && sg.Params.DoCount && sg.IsInternal()\n\tif uidCount {\n\t\treturn errors.New(\"uid count is not supported in the rdf output format\")\n\t}\n\tif sg.Params.Normalize {\n\t\treturn errors.New(\"normalize directive is not supported in the rdf output format\")\n\t}\n\tif sg.Params.IgnoreReflex {\n\t\treturn errors.New(\"ignorereflex directive is not supported in the rdf output format\")\n\t}\n\tif sg.SrcFunc != nil && sg.SrcFunc.Name == \"checkpwd\" {\n\t\treturn errors.New(\"chkpwd function is not supported in the rdf output format\")\n\t}\n\tif sg.Params.Facet != nil && !sg.Params.ExpandAll {\n\t\treturn errors.New(\"facets are not supported in the rdf output format\")\n\t}\n\treturn nil\n}\n\nfunc quotedNumber(val []byte) []byte {\n\tconst overhead = 2 // opening and closing quotes\n\tif len(val) > math.MaxInt-overhead {\n\t\t// Extremely unlikely, but handle overflow case\n\t\ttmpVal := make([]byte, 0)\n\t\ttmpVal = append(tmpVal, '\"')\n\t\ttmpVal = append(tmpVal, val...)\n\t\ttmpVal = append(tmpVal, '\"')\n\t\treturn tmpVal\n\t}\n\ttmpVal := make([]byte, 0, overhead+len(val))\n\ttmpVal = append(tmpVal, '\"')\n\ttmpVal = append(tmpVal, val...)\n\ttmpVal = append(tmpVal, '\"')","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/outputrdf.go#L214-L250","documentation":"RDF serialization does not support facet extraction unless facets are fully expanded. validateSubGraphForRDF rejects a sub-graph that requests specific facets (sg.Params.Facet set) without ExpandAll, since named facet projection cannot be expressed in RDF output.","triggerScenarios":"A query projecting specific facets (e.g. `friend @facets(since)`) with RDF output format; facets are only accepted when `@facets(*)` / ExpandAll is used.","commonSituations":"Exporting edge metadata (weights, timestamps, provenance) as RDF; queries ported from JSON where named facets worked.","solutions":["Use @facets with expand-all syntax so facets serialize as facet triples in RDF","Switch to JSON output for selective facet projection","Drop the facet projection if edge metadata is not needed in the export"],"exampleFix":"// before (rdf output)\n{ me(func: uid(0x1)) { friend @facets(since) } }\n// after\n{ me(func: uid(0x1)) { friend @facets } } // expand-all form, or use JSON output for @facets(since)","handlingStrategy":"validation","validationCode":"// Go: check facet projection form before RDF output\nif strings.Contains(query, \"@facets(\") && !strings.Contains(query, \"@facets(*)\") {\n    return errors.New(\"named facet projection needs JSON output; use @facets for RDF\")\n}","typeGuard":"func usesNamedFacets(dql string) bool {\n    return strings.Contains(dql, \"@facets(\")\n}","tryCatchPattern":"res, err := txn.QueryRDF(ctx, dql)\nif err != nil && strings.Contains(err.Error(), \"facets are not supported in the rdf\") {\n    return txn.Query(ctx, dql) // JSON handles named facets\n}","preventionTips":["Use expand-all @facets for RDF exports","Restrict named facet projection to JSON queries","Convert facet triples client-side if selective output is required"],"tags":["dgraph","rdf","facets","query-validation"],"backgroundTag":"feature-not-supported-in-rdf-output","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}