Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Discussion thread

here (<- link to

https://lists.apache.org

/list.html?dev@flink.apache.org)

/thread/ztyk68brsbmwwo66o1nvk3f6fqqhdxgk

Vote thread

here (<- link to

https://lists.apache.org

/list.html?dev@flink.apache.org)

JIRA

here (<- link to https://issues.apache.org/jira/browse/FLINK-XXXX)

Release

<Flink Version>

/thread/5txkmqx9wfj0lzg02vnrw99cj63b5zvj

JIRA

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyFLINK-33644

Release

1.19

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

...

ResolvedExpression:

Code Block
languagejava

public interface ResolvedExpression extends Expression {

    /**
     * Returns a string that fully serializes this instance. The serialized string can be used for
     * storing the query in, for example, a {@link org.apache.flink.table.catalog.Catalog} as a
     * view.
     *
     * @return detailed string for persisting in a catalog
     */
    default String asSerializableString() {
        throw new TableException(
                String.format(
                        "Expression '%s' is not string serializable. Currently, only expressions that "
                                + "originated from a SQL expression have a well-defined string representation.",
                        asSummaryString()));
    }
    
    ....
}

...

QueryOperation:

Code Block

public interface QueryOperation extends Operation {

    /**
     * Returns a string that fully serializes this instance. The serialized string can be used for
     * storing the query in e.g. a {@link org.apache.flink.table.catalog.Catalog} as a view.
     *
     * @return detailed string for persisting in a catalog
     * @see Operation#asSummaryString()
     */
    default String asSerializableString() {
        throw new UnsupportedOperationException(
                "QueryOperations are not string serializable for now.");
    }
 ....   
}

There is a very narrow subset of expressions that already follow this guideline. If an expression comes from the Planner and is backed by a `RexNode` it can be serialized to its SQL representation: https://github.com/apache/flink/blob/fa0dd3559e9697e21795a2634d8d99a0b7efdcf3/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/delegation/ParserImpl.java#L118


Example:

Code Block
env.from("customers")
                        .filter($("gender").isNotNull())
                        .filter($("has_newsletter").isEqual(true))
                        .filter($("date_of_birth").isGreaterOrEqual(LocalDate.parse("1980-01-01")))
                        .select(
                                $("name").upperCase(),
                                $("date_of_birth"))

results in:

Code Block
Project: (projections: [upper(name), date_of_birth, AddressNormalizer(street, zip_code, city)])
    Filter: (condition: [greaterThanOrEqual(date_of_birth, 1980-01-01)])
        Filter: (condition: [equals(has_newsletter, true)])
            Filter: (condition: [isNotNull(gender)])
                CatalogTable: (identifier: [default_catalog.default_database.customers], fields: [name, date_of_birth, street, zip_code, city, gender, has_newsletter])

which would get translated into a SQL:

Code Block
SELECT upper(name), date_of_birth FROM (
    SELECT * FROM (
        SELECT * FROM (
            SELECT * FROM ( 
                SELECT name, date_of_birth, street, zip_code, city, gender, has_newsletter FROM `default_catalog`.`default_database`.`customers`;
            ) WHERE gender IS NOT NULL
        ) WHERE has_newsletter = true
    ) WHERE date_of_birth >= 1980-01-01
) 


Functions requiring special syntax

...