prestodb/presto · error · PrestoException

Property %s for %s cannot have a null value

Error message

Property %s for %s cannot have a null value

What it means

While serializing table/schema properties back into SQL expressions (buildProperties), a property's stored value was null, which cannot be represented as a valid property expression. Presto throws the supplied errorCode to prevent emitting malformed CREATE TABLE/VIEW DDL.

Source

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

        }

        private List<Property> buildProperties(
                Object objectName,
                StandardErrorCode errorCode,
                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()))

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the connector's metadata source (metastore) and remove or fix the null-valued property entry
  2. Re-create the object with explicit, non-null property values
  3. Report/fix the connector so it never stores null property values

Example fix

// before (metastore entry)
{"partitioned_by": null}
// after
{"partitioned_by": ["ds"]}
Defensive patterns

Strategy: validation

Validate before calling

Map<String, Object> props = tableProperties;
props.forEach((k, v) -> { if (v == null) throw new IllegalStateException("null property: " + k); });

Type guard

function hasNoNullProperties(props) {
  return Object.entries(props).every(([, v]) => v !== null && v !== undefined);
}

Try / catch

try { session.execute("SHOW CREATE TABLE " + name); } catch (PrestoException e) { if (e.getMessage().contains("cannot have a null value")) { /* fix metastore entry */ } throw e; }

Prevention

When it happens

Trigger: Connector metadata or a stored view/materialized-view definition contains a property key with a null value in its properties map, and SHOW CREATE (or propertyNodes) rebuilds that DDL.

Common situations: Buggy connector returning null property values; corrupted metastore entries; properties written by an older/other engine version with null semantics Presto rejects.

Related errors


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