prestodb/presto · error · PrestoException

Property %s for %s should have value of type %s, not %s

Error message

Property %s for %s should have value of type %s, not %s

What it means

During DDL reconstruction, a property value's Java type did not match the PropertyMetadata declared Java type for that property (checked via Primitives.wrap(...).isInstance). Presto throws the supplied errorCode because emitting the value would produce a type-inconsistent property expression.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:736

                Map<String, Object> properties,
                Map<String, PropertyMetadata<?>> allProperties)
        {
            if (properties.isEmpty()) {
                return Collections.emptyList();
            }

            ImmutableSortedMap.Builder<String, Expression> sqlProperties = ImmutableSortedMap.naturalOrder();

            for (Map.Entry<String, Object> propertyEntry : properties.entrySet()) {
                String propertyName = propertyEntry.getKey();
                Object value = propertyEntry.getValue();
                if (value == null) {
                    throw new PrestoException(errorCode, format("Property %s for %s cannot have a null value", propertyName, objectName));
                }

                PropertyMetadata<?> property = allProperties.get(propertyName);
                if (!Primitives.wrap(property.getJavaType()).isInstance(value)) {
                    throw new PrestoException(errorCode, format(
                            "Property %s for %s should have value of type %s, not %s",
                            propertyName,
                            objectName,
                            property.getJavaType().getName(),
                            value.getClass().getName()));
                }

                Expression sqlExpression = getExpression(property, value);
                sqlProperties.put(propertyName, sqlExpression);
            }

            return sqlProperties.build().entrySet().stream()
                    .map(entry -> new Property(new Identifier(entry.getKey()), entry.getValue()))
                    .collect(toImmutableList());
        }

        private static String toQualifiedName(Object objectName, Optional<String> columnName)
        {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Correct the stored value's type in the metastore to match the property's declared Java type
  2. Align connector PropertyMetadata definitions with how values are actually stored (upgrade/downgrade the connector)
  3. Re-create the object with properly typed property values

Example fix

// before (stored as String)
{"external": "true"}
// after (Boolean per property metadata)
{"external": true}
Defensive patterns

Strategy: validation

Validate before calling

// check value types against declared PropertyMetadata before writing
if (!(value instanceof Boolean) && property.getJavaType() == Boolean.class)
    throw new IllegalArgumentException("property 'external' must be Boolean");

Type guard

function propertyTypesMatch(props, schema) {
  return Object.entries(props).every(([k, v]) =>
    schema[k] != null && v !== null && v.constructor === schema[k].javaType);
}

Try / catch

try { session.execute("SHOW CREATE TABLE " + name); } catch (PrestoException e) { if (e.getMessage().contains("should have value of type")) { /* correct stored type or connector metadata */ } throw e; }

Prevention

When it happens

Trigger: A properties map holds e.g. a String where the property declares Boolean/Long, typically from a connector or metastore that stored raw untyped values, when running SHOW CREATE or similar DDL rendering.

Common situations: Version skew between the engine writing the properties and the one reading them (type definition changed); hand-edited metastore entries; custom connectors declaring mismatched property types.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/d0bb1d14de2156ef. Report an issue: GitHub.