{"record":{"id":"347b9c542013e978","repo":"prestodb/presto","slug":"decoder-conversion-not-supported","errorCode":"DECODER_CONVERSION_NOT_SUPPORTED","errorMessage":"conversion to boolean not supported","messagePattern":"conversion to boolean not supported","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-record-decoder/src/main/java/com/facebook/presto/decoder/FieldValueProvider.java","lineNumber":27,"sourceCode":" * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.facebook.presto.decoder;\n\nimport com.facebook.presto.common.block.Block;\nimport com.facebook.presto.spi.PrestoException;\nimport io.airlift.slice.Slice;\n\n/**\n * Base class for all providers that return values for a selected column.\n */\npublic abstract class FieldValueProvider\n{\n    public boolean getBoolean()\n    {\n        throw new PrestoException(DecoderErrorCode.DECODER_CONVERSION_NOT_SUPPORTED, \"conversion to boolean not supported\");\n    }\n\n    public long getLong()\n    {\n        throw new PrestoException(DecoderErrorCode.DECODER_CONVERSION_NOT_SUPPORTED, \"conversion to long not supported\");\n    }\n\n    public double getDouble()\n    {\n        throw new PrestoException(DecoderErrorCode.DECODER_CONVERSION_NOT_SUPPORTED, \"conversion to double not supported\");\n    }\n\n    public Slice getSlice()\n    {\n        throw new PrestoException(DecoderErrorCode.DECODER_CONVERSION_NOT_SUPPORTED, \"conversion to Slice not supported\");\n    }\n\n    public Block getBlock()","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-record-decoder/src/main/java/com/facebook/presto/decoder/FieldValueProvider.java#L9-L45","documentation":"FieldValueProvider is the abstract base class for record-decoder column value providers. Its primitive accessors are deliberately non-abstract and throw DECODER_CONVERSION_NOT_SUPPORTED by default; subclasses override only the types their row format can actually produce. getBoolean() throws this when the concrete provider does not support boolean conversion, i.e. the decoded value is being read as a boolean by a provider that never implemented getBoolean().","triggerScenarios":"Calling getBoolean() on a FieldValueProvider subclass that did not override getBoolean() — typically when a column decoder (e.g. for JSON/CSV/Avro fields) produced a non-boolean value and downstream code (a RowDecoder path, combine, compareAndUpdateState, write, or serialize) requests it as a boolean.","commonSituations":"Mapping a Kafka/JSON/CSV column to a BOOLEAN Presto column while the decoder emits strings or numbers; a decoder subclass only overrides getLong()/getSlice() but the table schema declares the column as BOOLEAN; schema changes where a column type was switched to boolean without updating the decoder.","solutions":["Change the table/column type to match what the decoder actually produces (e.g. VARCHAR instead of BOOLEAN), or","Write/choose a FieldValueProvider subclass that overrides getBoolean() (or a ColumnDecoder that maps the raw value to boolean), or","Fix the row-format mapping so the field is decoded with a boolean-capable decoder before being accessed.","Wrap access in isNull()/type checks so getBoolean() is only called on providers known to support booleans."],"exampleFix":"// before: schema maps a JSON string field to BOOLEAN -> getBoolean() throws\n// after: decode with a boolean-capable provider\npublic class BooleanJsonFieldValueProvider extends JsonFieldValueProvider {\n    @Override\n    public boolean getBoolean()\n    {\n        return Boolean.parseBoolean(value.toStringUtf8());\n    }\n}","handlingStrategy":"try-catch","validationCode":"if (provider.isNull()) { handleNull(); } else { // only call getBoolean() if the provider/decoder for this column is boolean-capable\n    boolean v = provider.getBoolean(); }","typeGuard":"static boolean supportsBoolean(FieldValueProvider p) {\n    try { p.getBoolean(); return true; }\n    catch (PrestoException e) {\n        return e.getErrorCode().getCode() != DecoderErrorCode.DECODER_CONVERSION_NOT_SUPPORTED.toErrorCode().getCode();\n    }\n}","tryCatchPattern":"try {\n    boolean value = provider.getBoolean();\n}\ncatch (PrestoException e) {\n    if (e.getErrorCode().getCode() == DecoderErrorCode.DECODER_CONVERSION_NOT_SUPPORTED.toErrorCode().getCode()) {\n        // fall back: treat as unsupported column type, skip or log schema mismatch\n    } else {\n        throw e;\n    }\n}","preventionTips":["Match every column's declared type to a decoder/provider that overrides the corresponding getter","Check which accessors a FieldValueProvider subclass overrides before mapping a schema field to it","Call provider.isNull() before type accessors","Add unit tests using assertDecodedAs for every type your schema requests from a provider","Log the column mapping at connector startup so mismatches surface immediately"],"tags":["presto","decoder","type-conversion","record-decoder"],"backgroundTag":"decoder-conversion-not-supported","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}