{"id":"d2756c6c1e53f69b","repo":"knex/knex","slug":"json-superset-is-not-supported-by-redshift","errorCode":null,"errorMessage":"Json superset is not supported by Redshift","messagePattern":"Json superset is not supported by Redshift","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/dialects/redshift/query/redshift-querycompiler.js","lineNumber":151,"sourceCode":"  jsonInsert(params) {\n    throw new Error('Json insert is not supported by Redshift');\n  }\n\n  jsonRemove(params) {\n    throw new Error('Json remove is not supported by Redshift');\n  }\n\n  whereJsonPath(statement) {\n    return this._whereJsonPath(\n      'json_extract_path_text',\n      Object.assign({}, statement, {\n        path: this.client.toPathForJson(statement.path),\n      })\n    );\n  }\n\n  whereJsonSupersetOf(statement) {\n    throw new Error('Json superset is not supported by Redshift');\n  }\n\n  whereJsonSubsetOf(statement) {\n    throw new Error('Json subset is not supported by Redshift');\n  }\n\n  onJsonPathEquals(clause) {\n    return this._onJsonPathEquals('json_extract_path_text', clause);\n  }\n}\n\nmodule.exports = QueryCompiler_Redshift;\n","sourceCodeStart":133,"sourceCodeEnd":164,"githubUrl":"https://github.com/knex/knex/blob/e25d54bcb707714a17f5a5744eba5c4246bb4d1d/lib/dialects/redshift/query/redshift-querycompiler.js#L133-L164","documentation":"redshift-querycompiler.js:150 stubs whereJsonSupersetOf to throw. Redshift lacks a JSON containment operator (Postgres jsonb @> has no equivalent), so a 'where JSON contains X' predicate cannot be compiled. Knex throws at compile time instead of producing an error from the server.","triggerScenarios":"Calling any builder method that routes to whereJsonSupersetOf on a Redshift connection: knex('t').whereJsonSupersetOf('payload', {a:1}), or a higher-level helper that emits a superset predicate.","commonSituations":"Cross-dialect query builders assuming PG jsonb operators; migrating tag/attribute filtering from Postgres to Redshift; analytics pipelines that previously filtered by jsonb containment.","solutions":["Denormalize the searchable keys into indexed columns or a child table and filter on those.","Pull candidate rows (filtered by cheaper predicates) and apply the containment test in JavaScript.","If using Redshift SUPER columns, express containment via PartiQL in a raw where clause."],"exampleFix":"// before\nawait knex('docs').whereJsonSupersetOf('payload', { tags: 'x' });\n\n// after (filter in JS after a coarse select)\nconst rows = await knex('docs').select('*');\nconst matches = rows.filter(r =>\n  Object.entries({ tags: 'x' }).every(([k,v]) => r.payload?.[k] === v)\n);","handlingStrategy":"validation","validationCode":"function supportsJsonSuperset(client) {\n  return !/redshift/i.test(client.dialect || client.driverName || '');\n}\nif (supportsJsonSuperset(knex.client)) {\n  await knex('docs').whereJsonSupersetOf('payload', { tags: 'x' });\n}","typeGuard":"function isRedshiftDialect(client) {\n  const d = (client && (client.dialect || client.driverName)) || '';\n  return /redshift/i.test(d);\n}","tryCatchPattern":"try {\n  await knex('docs').whereJsonSupersetOf('payload', { tags: 'x' });\n} catch (err) {\n  if (/Json superset is not supported by Redshift/i.test(err.message)) {\n    // denormalize tags into a column, or filter in JS\n  } else throw err;\n}","preventionTips":["Denormalize searchable JSON keys into indexed columns for Redshift.","Branch containment queries by dialect.","Maintain a JSON-capability matrix per dialect."],"tags":["redshift","json","dialect-limitation","where"],"analyzedSha":"e25d54bcb707714a17f5a5744eba5c4246bb4d1d","analyzedAt":"2026-08-03T18:35:32.148Z","schemaVersion":2}