You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beam.apache.org by Alex Van Boxel <al...@vanboxel.be> on 2020/02/05 12:17:24 UTC

Re: [PROPOSAL] Beam Schema Options

I would appreciate if someone would look at the following PR and get it to
master:

https://github.com/apache/beam/pull/10413#

a lot of work needs to follow, but if we have the base already on master
the next layers can follow. As a reminder, this is the base proposal:
https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing

I've also looked for prior work, and saw that Spark actually has something
comparable:
https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html

but when the options are finished it will be far more powerful as it is not
limited on fields.

 _/
_/ Alex Van Boxel


On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org> wrote:

> Using schema types for the metadata values is a nice touch.
>
> Are the options expected to be common across many fields? Perhaps the name
> should be a URN to make it clear to be careful about collisions? (just a
> synonym for "name" in practice, but with different connotation)
>
> I generally like this... but the examples (all but one) are weird things
> that I don't really understand how they are done or who is responsible for
> them.
>
> One way to go is this: if options are maybe not understood by all
> consumers, then they can't really change behavior. Kind of like how URN and
> payload on a composite transform can be ignored and just the expansion used.
>
> Kenn
>
> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>
>> Hi everyone,
>>
>> I'm proud to announce my first real proposal. The proposal describes Beam
>> Schema Options. This is an extension to the Schema API to add typed meta
>> data to to Rows, Field and Logical Types:
>>
>>
>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>
>> To give you some context where this proposal comes from: We've been using
>> dynamic meta driven pipelines for a while, but till now in an awkward and
>> hacky way (see my talks at the previous Beam Summits). This proposal would
>> bring a good way to work with metadata on the metadata :-).
>>
>> The proposal points to 2 pull requests with the implementation, one for
>> the API another for translating proto options to beam options.
>>
>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>> feedback is welcome.
>>
>>  _/
>> _/ Alex Van Boxel
>>
>

Re: [PROPOSAL] Beam Schema Options

Posted by Alex Van Boxel <al...@vanboxel.be>.
Replying inline


> I'm not sure this belongs directly on schemas. I've had trouble
> reconciling that opinion, since the idea does seem very useful, and in fact
> I'm interested in using it myself. I think I've figured out my concern -
> what I really want is options for a (maybe portable) Table
>

I've build different pipelines where I've used options out-of-band. It work
but it's a pain... If you restrict it to a Table that you limit the usage
to only tables... as a Table has a schema I don't see the problem.

1) modify the behavior of the external system the IO is interfacing with
> (specify partitioning, indexing, etc..), or
> 2) define some transformation that should be done to the data adjacent to
> the IO (after an Input or before an Output) in Beam
>
(1) Is the sort of thing you described in the IO section [2] (aside from
> the PubSub example I added, since that's describing a transformation to do
> in Beam)
> I would argue that all of the other examples fall under (2) - data
> validation, adding computed columns, encryption, etc... are things that can
> be done in a transform
>

I think we do agree here about the different classes. But for
  1) add behaviour in the *IO* SDK is certainly interesting and adds added
value
  2) yes, everything described there should be handled in a *transform*...
but I don't think it should be part of the SDK, or at least not in *core*.
The options are just a tool for the SDK user to make transforms that handle
different schema's but are annotated by known, to the user, options. Here I
have an example that runs the beam SDK based on the PR.

[image: Screen Shot 2020-02-07 at 19.32.17.png]

Snipped from the proto:

	google.protobuf.StringValue zip_code = 7
[		(vptech.data.contract.v1.description) = "The VeePee Member postal
code (or the purchaser)",		(vptech.data.contract.v1.optional) =
true	];	MarketId market_id = 8
[		(vptech.data.contract.v1.description) = "The VeePee member
SiteID/martketID",		(vptech.data.contract.v1.enum_prefix) =
"MARKET_ID_"	];	Partner partner = 9
[		(vptech.data.contract.v1.enum_prefix) = "PARTNER_"	];

This is an ingestion pipeline for different contracts that act on the
options in the proto. *I don't want the options to be limited before or
after and IO*. As the above pipeline shows, this is a multi stage pipeline.
Concrete:
- Add Processing Time will change a field in the row and set the processing
time
- Validate Content will use *options* for validating
- Strip enum prefix changes a string the a enum_prefix *option* is defined
- Apply new schema shuffles to Row, flattening

OK, after this I write it to BigQuery... but I could do something else if I
wanted to. I don't want the SDK to limit me.


> I think we can make an analogy to a traditional database here:
> schema-aware Beam IOs are like Tables in a database, other PCollections are
> like intermediate results in a query. In a database, Tables can be defined
> with some DDL and have schema-level or column-level options that change
> system behavior, but intermediate results have no such capability.
>

I don't see why an intermediate transform should not have the ability to
change, add or remove options. The Apply New Schema for example, reads the
description *option* and adds it to the schema.


> Another point I think is worth discussing: is there value in making these
> options portable?
>
As it's currently defined I'm not sure there is - everything could be done
> within a single SDK. However, portable options on a portable table could be
> very powerful, since it could be used to configure cross-language IOs,
> perhaps with something like https://s.apache.org/xlang-table-provider/
>
>
I don't see the option proposal being in conflict with you proposal, the PR
adds the options to the portable schema. I certainly see value having it
portable. You don't want to loose meta information if you go cross
language. I've done a quick pass over your proposal (will take a closer
look later) and don't see conflicts with this proposal.

Re: [PROPOSAL] Beam Schema Options

Posted by Brian Hulette <bh...@google.com>.
Messed up my own short-link. It's https://s.apache.org/xlang-table-provider

On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com> wrote:

> I'm not sure this belongs directly on schemas. I've had trouble
> reconciling that opinion, since the idea does seem very useful, and in fact
> I'm interested in using it myself. I think I've figured out my concern -
> what I really want is options for a (maybe portable) Table.
>
> As I indicated in a comment in the doc [1] I still think all of the
> examples you've described only apply to IOs. To be clear, what I mean is
> that all of the examples either
> 1) modify the behavior of the external system the IO is interfacing with
> (specify partitioning, indexing, etc..), or
> 2) define some transformation that should be done to the data adjacent to
> the IO (after an Input or before an Output) in Beam
>
> (1) Is the sort of thing you described in the IO section [2] (aside from
> the PubSub example I added, since that's describing a transformation to do
> in Beam)
> I would argue that all of the other examples fall under (2) - data
> validation, adding computed columns, encryption, etc... are things that can
> be done in a transform
>
> I think we can make an analogy to a traditional database here:
> schema-aware Beam IOs are like Tables in a database, other PCollections are
> like intermediate results in a query. In a database, Tables can be defined
> with some DDL and have schema-level or column-level options that change
> system behavior, but intermediate results have no such capability.
>
>
> Another point I think is worth discussing: is there value in making these
> options portable?
> As it's currently defined I'm not sure there is - everything could be done
> within a single SDK. However, portable options on a portable table could be
> very powerful, since it could be used to configure cross-language IOs,
> perhaps with something like https://s.apache.org/xlang-table-provider/
>
> [1]
> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
> [2]
> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>
> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>
>> I would appreciate if someone would look at the following PR and get it
>> to master:
>>
>> https://github.com/apache/beam/pull/10413#
>>
>> a lot of work needs to follow, but if we have the base already on master
>> the next layers can follow. As a reminder, this is the base proposal:
>>
>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>
>> I've also looked for prior work, and saw that Spark actually has
>> something comparable:
>>
>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>
>> but when the options are finished it will be far more powerful as it is
>> not limited on fields.
>>
>>  _/
>> _/ Alex Van Boxel
>>
>>
>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org> wrote:
>>
>>> Using schema types for the metadata values is a nice touch.
>>>
>>> Are the options expected to be common across many fields? Perhaps the
>>> name should be a URN to make it clear to be careful about collisions? (just
>>> a synonym for "name" in practice, but with different connotation)
>>>
>>> I generally like this... but the examples (all but one) are weird things
>>> that I don't really understand how they are done or who is responsible for
>>> them.
>>>
>>> One way to go is this: if options are maybe not understood by all
>>> consumers, then they can't really change behavior. Kind of like how URN and
>>> payload on a composite transform can be ignored and just the expansion used.
>>>
>>> Kenn
>>>
>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>>
>>>> Hi everyone,
>>>>
>>>> I'm proud to announce my first real proposal. The proposal describes
>>>> Beam Schema Options. This is an extension to the Schema API to add typed
>>>> meta data to to Rows, Field and Logical Types:
>>>>
>>>>
>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>
>>>> To give you some context where this proposal comes from: We've been
>>>> using dynamic meta driven pipelines for a while, but till now in an
>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>
>>>> The proposal points to 2 pull requests with the implementation, one for
>>>> the API another for translating proto options to beam options.
>>>>
>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>>>> feedback is welcome.
>>>>
>>>>  _/
>>>> _/ Alex Van Boxel
>>>>
>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Brian Hulette <bh...@google.com>.
> 2) yes, everything described there should be handled in a *transform*...
but I don't think it should be part of the SDK, or at least not in *core*.
The options are just a tool for the SDK user to make transforms that handle
different schema's but are annotated by known, to the user, options. Here I
have an example that runs the beam SDK based on the PR.
I don't think that transforms that act on options should be in core, nor
would they need to be. If options existed only on tables, any
implementation of BeamSqlTable [1] in Beam or in user code could act on the
options in their #buildIOReader or #buildIOWriter implementation. In my
mind, the only place we may have transforms in Beam that act on the options
would be in the built-in tables in SQL (like [2,3] which already do this
with some json schema-level TBLPROPERTIES).


> I don't see the option proposal being in conflict with you proposal, the
PR adds the options to the portable schema.
Absolutely agree, the proposals are not in conflict. Whether the options
are on the Table itself or the Table's schema I would use them for a xlang
Table.
I'm just suggesting we consider limiting options to IO for simplicity if
modifying IO is their primary application. Maybe doing so alleviates Kenn's
concern some.


> A common rationale is to preserve fidelity. For instance, reading protos,
projecting out a few fields, writing protos back out.
This does sound reasonable, but could you do that in practice? Wouldn't you
need to define a proto message type that describes the output anyway? I
suppose you could generate the output message type at pipeline construction
time and write it somewhere for downstream consumers.


Sorry to be contradictory. I do think this is a good proposal and I'm
excited about the possibilities, whether the options are on Tables only or
on every schema.

Brian

[1]
https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/BeamSqlTable.java
[2]
https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/pubsub/PubsubIOJsonTable.java
[3]
https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BigQueryTable.java


On Sat, Feb 8, 2020 at 12:25 AM Alex Van Boxel <al...@vanboxel.be> wrote:

> I'll be happy to make a BIP out of it.
>
> Kenneth, about your concern: I first cramped all our proto option data
> into the meta data, and that worked but was very ugly. You had to parse the
> binary data in the transform (very ugly). Switching to Beam options the
> code became more readable, and it made more sense to the team.
>
> On Sat, Feb 8, 2020, 04:33 Kenneth Knowles <ke...@apache.org> wrote:
>
>> All fair points. I think it is a good proposal. We already know of
>> existing and future uses for it.
>>
>> I don't think my concerns are actually answered by this discussion. Does
>> this allow/encourage creation of a PCollection that you can't make sense of
>> (or can't make *good* sense of) without understanding the options? We don't
>> have to answer that now and maybe it is unanswerable. If we look at proto
>> options as an example it seems to be mostly OK.
>>
>> I think the risk is inseparable from how powerful it could be. So it is
>> worth accepting. If my fears come to pass, it will still mean that Beam is
>> being useful in new and unexpected ways, so that's not so bad :-)
>>
>> Would it make sense to write this up as a BIP, to help bootstrap the wiki
>> page for them?
>>
>> Kenn
>>
>> On Fri, Feb 7, 2020 at 2:05 PM Reuven Lax <re...@google.com> wrote:
>>
>>> True - however at some level that's up to the user. We should be
>>> diligent that we don't implement core functionality this way (so far schema
>>> metadata has only been used for the fidelity use case above). However if
>>> some users wants to use it more extensively in their pipeline, that's up to
>>> them.
>>>
>>> Reuven
>>>
>>> On Fri, Feb 7, 2020 at 2:02 PM Kenneth Knowles <ke...@apache.org> wrote:
>>>
>>>> It is a good point that it applies to configuring sources and sinks
>>>> mostly, or external data more generally.
>>>>
>>>> What I worry about is that metadata channels like this tend to take
>>>> over everything, and do it worse than more structured approach.
>>>>
>>>> As an exaggerated example which is not actually that far-fetched,
>>>> schemas could have a single type: bytes. And then the options on the fields
>>>> would say how to encode/decode the bytes. Now you've created a system where
>>>> the options are the main event and are actually core to the system. My
>>>> expectation is that this will almost certainly happen unless we are
>>>> vigilant about preventing core features from landing as options.
>>>>
>>>> Kenn
>>>>
>>>> On Fri, Feb 7, 2020 at 1:56 PM Reuven Lax <re...@google.com> wrote:
>>>>
>>>>> I disagree - I've had several cases where user options on fields are
>>>>> very useful internally.
>>>>>
>>>>> A common rationale is to preserve fidelity. For instance, reading
>>>>> protos, projecting out a few fields, writing protos back out. You want to
>>>>> be able to nicely map protos to Beam schemas, but also preserve all the
>>>>> extra metadata on proto fields. This metadata has to carry through on all
>>>>> intermediate PCollections and schemas, so it makes sense to put it on the
>>>>> field.
>>>>>
>>>>> Another example: it provides a nice extension point for annotation
>>>>> extensions to a field. These are often things like Optional or Taint
>>>>> markings that don't change the semantic interpretation of the type (so
>>>>> shouldn't be a logical type), but do provide extra information about the
>>>>> field.
>>>>>
>>>>> Reuven
>>>>>
>>>>> On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com>
>>>>> wrote:
>>>>>
>>>>>> I'm not sure this belongs directly on schemas. I've had trouble
>>>>>> reconciling that opinion, since the idea does seem very useful, and in fact
>>>>>> I'm interested in using it myself. I think I've figured out my concern -
>>>>>> what I really want is options for a (maybe portable) Table.
>>>>>>
>>>>>> As I indicated in a comment in the doc [1] I still think all of the
>>>>>> examples you've described only apply to IOs. To be clear, what I mean is
>>>>>> that all of the examples either
>>>>>> 1) modify the behavior of the external system the IO is interfacing
>>>>>> with (specify partitioning, indexing, etc..), or
>>>>>> 2) define some transformation that should be done to the data
>>>>>> adjacent to the IO (after an Input or before an Output) in Beam
>>>>>>
>>>>>> (1) Is the sort of thing you described in the IO section [2] (aside
>>>>>> from the PubSub example I added, since that's describing a transformation
>>>>>> to do in Beam)
>>>>>> I would argue that all of the other examples fall under (2) - data
>>>>>> validation, adding computed columns, encryption, etc... are things that can
>>>>>> be done in a transform
>>>>>>
>>>>>> I think we can make an analogy to a traditional database here:
>>>>>> schema-aware Beam IOs are like Tables in a database, other PCollections are
>>>>>> like intermediate results in a query. In a database, Tables can be defined
>>>>>> with some DDL and have schema-level or column-level options that change
>>>>>> system behavior, but intermediate results have no such capability.
>>>>>>
>>>>>>
>>>>>> Another point I think is worth discussing: is there value in making
>>>>>> these options portable?
>>>>>> As it's currently defined I'm not sure there is - everything could be
>>>>>> done within a single SDK. However, portable options on a portable table
>>>>>> could be very powerful, since it could be used to configure cross-language
>>>>>> IOs, perhaps with something like
>>>>>> https://s.apache.org/xlang-table-provider/
>>>>>>
>>>>>> [1]
>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
>>>>>> [2]
>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>>>>>>
>>>>>> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>>>>>
>>>>>>> I would appreciate if someone would look at the following PR and get
>>>>>>> it to master:
>>>>>>>
>>>>>>> https://github.com/apache/beam/pull/10413#
>>>>>>>
>>>>>>> a lot of work needs to follow, but if we have the base already on
>>>>>>> master the next layers can follow. As a reminder, this is the base proposal:
>>>>>>>
>>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>>>
>>>>>>> I've also looked for prior work, and saw that Spark actually has
>>>>>>> something comparable:
>>>>>>>
>>>>>>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>>>>>>
>>>>>>> but when the options are finished it will be far more powerful as it
>>>>>>> is not limited on fields.
>>>>>>>
>>>>>>>  _/
>>>>>>> _/ Alex Van Boxel
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Using schema types for the metadata values is a nice touch.
>>>>>>>>
>>>>>>>> Are the options expected to be common across many fields? Perhaps
>>>>>>>> the name should be a URN to make it clear to be careful about collisions?
>>>>>>>> (just a synonym for "name" in practice, but with different connotation)
>>>>>>>>
>>>>>>>> I generally like this... but the examples (all but one) are weird
>>>>>>>> things that I don't really understand how they are done or who is
>>>>>>>> responsible for them.
>>>>>>>>
>>>>>>>> One way to go is this: if options are maybe not understood by all
>>>>>>>> consumers, then they can't really change behavior. Kind of like how URN and
>>>>>>>> payload on a composite transform can be ignored and just the expansion used.
>>>>>>>>
>>>>>>>> Kenn
>>>>>>>>
>>>>>>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi everyone,
>>>>>>>>>
>>>>>>>>> I'm proud to announce my first real proposal. The proposal
>>>>>>>>> describes Beam Schema Options. This is an extension to the Schema API to
>>>>>>>>> add typed meta data to to Rows, Field and Logical Types:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>>>>>
>>>>>>>>> To give you some context where this proposal comes from: We've
>>>>>>>>> been using dynamic meta driven pipelines for a while, but till now in an
>>>>>>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>>>>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>>>>>>
>>>>>>>>> The proposal points to 2 pull requests with the implementation,
>>>>>>>>> one for the API another for translating proto options to beam options.
>>>>>>>>>
>>>>>>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback.
>>>>>>>>> All feedback is welcome.
>>>>>>>>>
>>>>>>>>>  _/
>>>>>>>>> _/ Alex Van Boxel
>>>>>>>>>
>>>>>>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Alex Van Boxel <al...@vanboxel.be>.
I'll be happy to make a BIP out of it.

Kenneth, about your concern: I first cramped all our proto option data into
the meta data, and that worked but was very ugly. You had to parse the
binary data in the transform (very ugly). Switching to Beam options the
code became more readable, and it made more sense to the team.

On Sat, Feb 8, 2020, 04:33 Kenneth Knowles <ke...@apache.org> wrote:

> All fair points. I think it is a good proposal. We already know of
> existing and future uses for it.
>
> I don't think my concerns are actually answered by this discussion. Does
> this allow/encourage creation of a PCollection that you can't make sense of
> (or can't make *good* sense of) without understanding the options? We don't
> have to answer that now and maybe it is unanswerable. If we look at proto
> options as an example it seems to be mostly OK.
>
> I think the risk is inseparable from how powerful it could be. So it is
> worth accepting. If my fears come to pass, it will still mean that Beam is
> being useful in new and unexpected ways, so that's not so bad :-)
>
> Would it make sense to write this up as a BIP, to help bootstrap the wiki
> page for them?
>
> Kenn
>
> On Fri, Feb 7, 2020 at 2:05 PM Reuven Lax <re...@google.com> wrote:
>
>> True - however at some level that's up to the user. We should be diligent
>> that we don't implement core functionality this way (so far schema metadata
>> has only been used for the fidelity use case above). However if some users
>> wants to use it more extensively in their pipeline, that's up to them.
>>
>> Reuven
>>
>> On Fri, Feb 7, 2020 at 2:02 PM Kenneth Knowles <ke...@apache.org> wrote:
>>
>>> It is a good point that it applies to configuring sources and sinks
>>> mostly, or external data more generally.
>>>
>>> What I worry about is that metadata channels like this tend to take over
>>> everything, and do it worse than more structured approach.
>>>
>>> As an exaggerated example which is not actually that far-fetched,
>>> schemas could have a single type: bytes. And then the options on the fields
>>> would say how to encode/decode the bytes. Now you've created a system where
>>> the options are the main event and are actually core to the system. My
>>> expectation is that this will almost certainly happen unless we are
>>> vigilant about preventing core features from landing as options.
>>>
>>> Kenn
>>>
>>> On Fri, Feb 7, 2020 at 1:56 PM Reuven Lax <re...@google.com> wrote:
>>>
>>>> I disagree - I've had several cases where user options on fields are
>>>> very useful internally.
>>>>
>>>> A common rationale is to preserve fidelity. For instance, reading
>>>> protos, projecting out a few fields, writing protos back out. You want to
>>>> be able to nicely map protos to Beam schemas, but also preserve all the
>>>> extra metadata on proto fields. This metadata has to carry through on all
>>>> intermediate PCollections and schemas, so it makes sense to put it on the
>>>> field.
>>>>
>>>> Another example: it provides a nice extension point for annotation
>>>> extensions to a field. These are often things like Optional or Taint
>>>> markings that don't change the semantic interpretation of the type (so
>>>> shouldn't be a logical type), but do provide extra information about the
>>>> field.
>>>>
>>>> Reuven
>>>>
>>>> On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com>
>>>> wrote:
>>>>
>>>>> I'm not sure this belongs directly on schemas. I've had trouble
>>>>> reconciling that opinion, since the idea does seem very useful, and in fact
>>>>> I'm interested in using it myself. I think I've figured out my concern -
>>>>> what I really want is options for a (maybe portable) Table.
>>>>>
>>>>> As I indicated in a comment in the doc [1] I still think all of the
>>>>> examples you've described only apply to IOs. To be clear, what I mean is
>>>>> that all of the examples either
>>>>> 1) modify the behavior of the external system the IO is interfacing
>>>>> with (specify partitioning, indexing, etc..), or
>>>>> 2) define some transformation that should be done to the data adjacent
>>>>> to the IO (after an Input or before an Output) in Beam
>>>>>
>>>>> (1) Is the sort of thing you described in the IO section [2] (aside
>>>>> from the PubSub example I added, since that's describing a transformation
>>>>> to do in Beam)
>>>>> I would argue that all of the other examples fall under (2) - data
>>>>> validation, adding computed columns, encryption, etc... are things that can
>>>>> be done in a transform
>>>>>
>>>>> I think we can make an analogy to a traditional database here:
>>>>> schema-aware Beam IOs are like Tables in a database, other PCollections are
>>>>> like intermediate results in a query. In a database, Tables can be defined
>>>>> with some DDL and have schema-level or column-level options that change
>>>>> system behavior, but intermediate results have no such capability.
>>>>>
>>>>>
>>>>> Another point I think is worth discussing: is there value in making
>>>>> these options portable?
>>>>> As it's currently defined I'm not sure there is - everything could be
>>>>> done within a single SDK. However, portable options on a portable table
>>>>> could be very powerful, since it could be used to configure cross-language
>>>>> IOs, perhaps with something like
>>>>> https://s.apache.org/xlang-table-provider/
>>>>>
>>>>> [1]
>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
>>>>> [2]
>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>>>>>
>>>>> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>>>>
>>>>>> I would appreciate if someone would look at the following PR and get
>>>>>> it to master:
>>>>>>
>>>>>> https://github.com/apache/beam/pull/10413#
>>>>>>
>>>>>> a lot of work needs to follow, but if we have the base already on
>>>>>> master the next layers can follow. As a reminder, this is the base proposal:
>>>>>>
>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>>
>>>>>> I've also looked for prior work, and saw that Spark actually has
>>>>>> something comparable:
>>>>>>
>>>>>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>>>>>
>>>>>> but when the options are finished it will be far more powerful as it
>>>>>> is not limited on fields.
>>>>>>
>>>>>>  _/
>>>>>> _/ Alex Van Boxel
>>>>>>
>>>>>>
>>>>>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org>
>>>>>> wrote:
>>>>>>
>>>>>>> Using schema types for the metadata values is a nice touch.
>>>>>>>
>>>>>>> Are the options expected to be common across many fields? Perhaps
>>>>>>> the name should be a URN to make it clear to be careful about collisions?
>>>>>>> (just a synonym for "name" in practice, but with different connotation)
>>>>>>>
>>>>>>> I generally like this... but the examples (all but one) are weird
>>>>>>> things that I don't really understand how they are done or who is
>>>>>>> responsible for them.
>>>>>>>
>>>>>>> One way to go is this: if options are maybe not understood by all
>>>>>>> consumers, then they can't really change behavior. Kind of like how URN and
>>>>>>> payload on a composite transform can be ignored and just the expansion used.
>>>>>>>
>>>>>>> Kenn
>>>>>>>
>>>>>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi everyone,
>>>>>>>>
>>>>>>>> I'm proud to announce my first real proposal. The proposal
>>>>>>>> describes Beam Schema Options. This is an extension to the Schema API to
>>>>>>>> add typed meta data to to Rows, Field and Logical Types:
>>>>>>>>
>>>>>>>>
>>>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>>>>
>>>>>>>> To give you some context where this proposal comes from: We've been
>>>>>>>> using dynamic meta driven pipelines for a while, but till now in an
>>>>>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>>>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>>>>>
>>>>>>>> The proposal points to 2 pull requests with the implementation, one
>>>>>>>> for the API another for translating proto options to beam options.
>>>>>>>>
>>>>>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback.
>>>>>>>> All feedback is welcome.
>>>>>>>>
>>>>>>>>  _/
>>>>>>>> _/ Alex Van Boxel
>>>>>>>>
>>>>>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Kenneth Knowles <ke...@apache.org>.
All fair points. I think it is a good proposal. We already know of existing
and future uses for it.

I don't think my concerns are actually answered by this discussion. Does
this allow/encourage creation of a PCollection that you can't make sense of
(or can't make *good* sense of) without understanding the options? We don't
have to answer that now and maybe it is unanswerable. If we look at proto
options as an example it seems to be mostly OK.

I think the risk is inseparable from how powerful it could be. So it is
worth accepting. If my fears come to pass, it will still mean that Beam is
being useful in new and unexpected ways, so that's not so bad :-)

Would it make sense to write this up as a BIP, to help bootstrap the wiki
page for them?

Kenn

On Fri, Feb 7, 2020 at 2:05 PM Reuven Lax <re...@google.com> wrote:

> True - however at some level that's up to the user. We should be diligent
> that we don't implement core functionality this way (so far schema metadata
> has only been used for the fidelity use case above). However if some users
> wants to use it more extensively in their pipeline, that's up to them.
>
> Reuven
>
> On Fri, Feb 7, 2020 at 2:02 PM Kenneth Knowles <ke...@apache.org> wrote:
>
>> It is a good point that it applies to configuring sources and sinks
>> mostly, or external data more generally.
>>
>> What I worry about is that metadata channels like this tend to take over
>> everything, and do it worse than more structured approach.
>>
>> As an exaggerated example which is not actually that far-fetched, schemas
>> could have a single type: bytes. And then the options on the fields would
>> say how to encode/decode the bytes. Now you've created a system where the
>> options are the main event and are actually core to the system. My
>> expectation is that this will almost certainly happen unless we are
>> vigilant about preventing core features from landing as options.
>>
>> Kenn
>>
>> On Fri, Feb 7, 2020 at 1:56 PM Reuven Lax <re...@google.com> wrote:
>>
>>> I disagree - I've had several cases where user options on fields are
>>> very useful internally.
>>>
>>> A common rationale is to preserve fidelity. For instance, reading
>>> protos, projecting out a few fields, writing protos back out. You want to
>>> be able to nicely map protos to Beam schemas, but also preserve all the
>>> extra metadata on proto fields. This metadata has to carry through on all
>>> intermediate PCollections and schemas, so it makes sense to put it on the
>>> field.
>>>
>>> Another example: it provides a nice extension point for annotation
>>> extensions to a field. These are often things like Optional or Taint
>>> markings that don't change the semantic interpretation of the type (so
>>> shouldn't be a logical type), but do provide extra information about the
>>> field.
>>>
>>> Reuven
>>>
>>> On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com>
>>> wrote:
>>>
>>>> I'm not sure this belongs directly on schemas. I've had trouble
>>>> reconciling that opinion, since the idea does seem very useful, and in fact
>>>> I'm interested in using it myself. I think I've figured out my concern -
>>>> what I really want is options for a (maybe portable) Table.
>>>>
>>>> As I indicated in a comment in the doc [1] I still think all of the
>>>> examples you've described only apply to IOs. To be clear, what I mean is
>>>> that all of the examples either
>>>> 1) modify the behavior of the external system the IO is interfacing
>>>> with (specify partitioning, indexing, etc..), or
>>>> 2) define some transformation that should be done to the data adjacent
>>>> to the IO (after an Input or before an Output) in Beam
>>>>
>>>> (1) Is the sort of thing you described in the IO section [2] (aside
>>>> from the PubSub example I added, since that's describing a transformation
>>>> to do in Beam)
>>>> I would argue that all of the other examples fall under (2) - data
>>>> validation, adding computed columns, encryption, etc... are things that can
>>>> be done in a transform
>>>>
>>>> I think we can make an analogy to a traditional database here:
>>>> schema-aware Beam IOs are like Tables in a database, other PCollections are
>>>> like intermediate results in a query. In a database, Tables can be defined
>>>> with some DDL and have schema-level or column-level options that change
>>>> system behavior, but intermediate results have no such capability.
>>>>
>>>>
>>>> Another point I think is worth discussing: is there value in making
>>>> these options portable?
>>>> As it's currently defined I'm not sure there is - everything could be
>>>> done within a single SDK. However, portable options on a portable table
>>>> could be very powerful, since it could be used to configure cross-language
>>>> IOs, perhaps with something like
>>>> https://s.apache.org/xlang-table-provider/
>>>>
>>>> [1]
>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
>>>> [2]
>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>>>>
>>>> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>>>
>>>>> I would appreciate if someone would look at the following PR and get
>>>>> it to master:
>>>>>
>>>>> https://github.com/apache/beam/pull/10413#
>>>>>
>>>>> a lot of work needs to follow, but if we have the base already on
>>>>> master the next layers can follow. As a reminder, this is the base proposal:
>>>>>
>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>
>>>>> I've also looked for prior work, and saw that Spark actually has
>>>>> something comparable:
>>>>>
>>>>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>>>>
>>>>> but when the options are finished it will be far more powerful as it
>>>>> is not limited on fields.
>>>>>
>>>>>  _/
>>>>> _/ Alex Van Boxel
>>>>>
>>>>>
>>>>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org>
>>>>> wrote:
>>>>>
>>>>>> Using schema types for the metadata values is a nice touch.
>>>>>>
>>>>>> Are the options expected to be common across many fields? Perhaps the
>>>>>> name should be a URN to make it clear to be careful about collisions? (just
>>>>>> a synonym for "name" in practice, but with different connotation)
>>>>>>
>>>>>> I generally like this... but the examples (all but one) are weird
>>>>>> things that I don't really understand how they are done or who is
>>>>>> responsible for them.
>>>>>>
>>>>>> One way to go is this: if options are maybe not understood by all
>>>>>> consumers, then they can't really change behavior. Kind of like how URN and
>>>>>> payload on a composite transform can be ignored and just the expansion used.
>>>>>>
>>>>>> Kenn
>>>>>>
>>>>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi everyone,
>>>>>>>
>>>>>>> I'm proud to announce my first real proposal. The proposal describes
>>>>>>> Beam Schema Options. This is an extension to the Schema API to add typed
>>>>>>> meta data to to Rows, Field and Logical Types:
>>>>>>>
>>>>>>>
>>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>>>
>>>>>>> To give you some context where this proposal comes from: We've been
>>>>>>> using dynamic meta driven pipelines for a while, but till now in an
>>>>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>>>>
>>>>>>> The proposal points to 2 pull requests with the implementation, one
>>>>>>> for the API another for translating proto options to beam options.
>>>>>>>
>>>>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>>>>>>> feedback is welcome.
>>>>>>>
>>>>>>>  _/
>>>>>>> _/ Alex Van Boxel
>>>>>>>
>>>>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Reuven Lax <re...@google.com>.
True - however at some level that's up to the user. We should be diligent
that we don't implement core functionality this way (so far schema metadata
has only been used for the fidelity use case above). However if some users
wants to use it more extensively in their pipeline, that's up to them.

Reuven

On Fri, Feb 7, 2020 at 2:02 PM Kenneth Knowles <ke...@apache.org> wrote:

> It is a good point that it applies to configuring sources and sinks
> mostly, or external data more generally.
>
> What I worry about is that metadata channels like this tend to take over
> everything, and do it worse than more structured approach.
>
> As an exaggerated example which is not actually that far-fetched, schemas
> could have a single type: bytes. And then the options on the fields would
> say how to encode/decode the bytes. Now you've created a system where the
> options are the main event and are actually core to the system. My
> expectation is that this will almost certainly happen unless we are
> vigilant about preventing core features from landing as options.
>
> Kenn
>
> On Fri, Feb 7, 2020 at 1:56 PM Reuven Lax <re...@google.com> wrote:
>
>> I disagree - I've had several cases where user options on fields are very
>> useful internally.
>>
>> A common rationale is to preserve fidelity. For instance, reading protos,
>> projecting out a few fields, writing protos back out. You want to be able
>> to nicely map protos to Beam schemas, but also preserve all the extra
>> metadata on proto fields. This metadata has to carry through on all
>> intermediate PCollections and schemas, so it makes sense to put it on the
>> field.
>>
>> Another example: it provides a nice extension point for annotation
>> extensions to a field. These are often things like Optional or Taint
>> markings that don't change the semantic interpretation of the type (so
>> shouldn't be a logical type), but do provide extra information about the
>> field.
>>
>> Reuven
>>
>> On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com> wrote:
>>
>>> I'm not sure this belongs directly on schemas. I've had trouble
>>> reconciling that opinion, since the idea does seem very useful, and in fact
>>> I'm interested in using it myself. I think I've figured out my concern -
>>> what I really want is options for a (maybe portable) Table.
>>>
>>> As I indicated in a comment in the doc [1] I still think all of the
>>> examples you've described only apply to IOs. To be clear, what I mean is
>>> that all of the examples either
>>> 1) modify the behavior of the external system the IO is interfacing with
>>> (specify partitioning, indexing, etc..), or
>>> 2) define some transformation that should be done to the data adjacent
>>> to the IO (after an Input or before an Output) in Beam
>>>
>>> (1) Is the sort of thing you described in the IO section [2] (aside from
>>> the PubSub example I added, since that's describing a transformation to do
>>> in Beam)
>>> I would argue that all of the other examples fall under (2) - data
>>> validation, adding computed columns, encryption, etc... are things that can
>>> be done in a transform
>>>
>>> I think we can make an analogy to a traditional database here:
>>> schema-aware Beam IOs are like Tables in a database, other PCollections are
>>> like intermediate results in a query. In a database, Tables can be defined
>>> with some DDL and have schema-level or column-level options that change
>>> system behavior, but intermediate results have no such capability.
>>>
>>>
>>> Another point I think is worth discussing: is there value in making
>>> these options portable?
>>> As it's currently defined I'm not sure there is - everything could be
>>> done within a single SDK. However, portable options on a portable table
>>> could be very powerful, since it could be used to configure cross-language
>>> IOs, perhaps with something like
>>> https://s.apache.org/xlang-table-provider/
>>>
>>> [1]
>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
>>> [2]
>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>>>
>>> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>>
>>>> I would appreciate if someone would look at the following PR and get it
>>>> to master:
>>>>
>>>> https://github.com/apache/beam/pull/10413#
>>>>
>>>> a lot of work needs to follow, but if we have the base already on
>>>> master the next layers can follow. As a reminder, this is the base proposal:
>>>>
>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>
>>>> I've also looked for prior work, and saw that Spark actually has
>>>> something comparable:
>>>>
>>>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>>>
>>>> but when the options are finished it will be far more powerful as it is
>>>> not limited on fields.
>>>>
>>>>  _/
>>>> _/ Alex Van Boxel
>>>>
>>>>
>>>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org>
>>>> wrote:
>>>>
>>>>> Using schema types for the metadata values is a nice touch.
>>>>>
>>>>> Are the options expected to be common across many fields? Perhaps the
>>>>> name should be a URN to make it clear to be careful about collisions? (just
>>>>> a synonym for "name" in practice, but with different connotation)
>>>>>
>>>>> I generally like this... but the examples (all but one) are weird
>>>>> things that I don't really understand how they are done or who is
>>>>> responsible for them.
>>>>>
>>>>> One way to go is this: if options are maybe not understood by all
>>>>> consumers, then they can't really change behavior. Kind of like how URN and
>>>>> payload on a composite transform can be ignored and just the expansion used.
>>>>>
>>>>> Kenn
>>>>>
>>>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be>
>>>>> wrote:
>>>>>
>>>>>> Hi everyone,
>>>>>>
>>>>>> I'm proud to announce my first real proposal. The proposal describes
>>>>>> Beam Schema Options. This is an extension to the Schema API to add typed
>>>>>> meta data to to Rows, Field and Logical Types:
>>>>>>
>>>>>>
>>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>>
>>>>>> To give you some context where this proposal comes from: We've been
>>>>>> using dynamic meta driven pipelines for a while, but till now in an
>>>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>>>
>>>>>> The proposal points to 2 pull requests with the implementation, one
>>>>>> for the API another for translating proto options to beam options.
>>>>>>
>>>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>>>>>> feedback is welcome.
>>>>>>
>>>>>>  _/
>>>>>> _/ Alex Van Boxel
>>>>>>
>>>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Kenneth Knowles <ke...@apache.org>.
It is a good point that it applies to configuring sources and sinks mostly,
or external data more generally.

What I worry about is that metadata channels like this tend to take over
everything, and do it worse than more structured approach.

As an exaggerated example which is not actually that far-fetched, schemas
could have a single type: bytes. And then the options on the fields would
say how to encode/decode the bytes. Now you've created a system where the
options are the main event and are actually core to the system. My
expectation is that this will almost certainly happen unless we are
vigilant about preventing core features from landing as options.

Kenn

On Fri, Feb 7, 2020 at 1:56 PM Reuven Lax <re...@google.com> wrote:

> I disagree - I've had several cases where user options on fields are very
> useful internally.
>
> A common rationale is to preserve fidelity. For instance, reading protos,
> projecting out a few fields, writing protos back out. You want to be able
> to nicely map protos to Beam schemas, but also preserve all the extra
> metadata on proto fields. This metadata has to carry through on all
> intermediate PCollections and schemas, so it makes sense to put it on the
> field.
>
> Another example: it provides a nice extension point for annotation
> extensions to a field. These are often things like Optional or Taint
> markings that don't change the semantic interpretation of the type (so
> shouldn't be a logical type), but do provide extra information about the
> field.
>
> Reuven
>
> On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com> wrote:
>
>> I'm not sure this belongs directly on schemas. I've had trouble
>> reconciling that opinion, since the idea does seem very useful, and in fact
>> I'm interested in using it myself. I think I've figured out my concern -
>> what I really want is options for a (maybe portable) Table.
>>
>> As I indicated in a comment in the doc [1] I still think all of the
>> examples you've described only apply to IOs. To be clear, what I mean is
>> that all of the examples either
>> 1) modify the behavior of the external system the IO is interfacing with
>> (specify partitioning, indexing, etc..), or
>> 2) define some transformation that should be done to the data adjacent to
>> the IO (after an Input or before an Output) in Beam
>>
>> (1) Is the sort of thing you described in the IO section [2] (aside from
>> the PubSub example I added, since that's describing a transformation to do
>> in Beam)
>> I would argue that all of the other examples fall under (2) - data
>> validation, adding computed columns, encryption, etc... are things that can
>> be done in a transform
>>
>> I think we can make an analogy to a traditional database here:
>> schema-aware Beam IOs are like Tables in a database, other PCollections are
>> like intermediate results in a query. In a database, Tables can be defined
>> with some DDL and have schema-level or column-level options that change
>> system behavior, but intermediate results have no such capability.
>>
>>
>> Another point I think is worth discussing: is there value in making these
>> options portable?
>> As it's currently defined I'm not sure there is - everything could be
>> done within a single SDK. However, portable options on a portable table
>> could be very powerful, since it could be used to configure cross-language
>> IOs, perhaps with something like
>> https://s.apache.org/xlang-table-provider/
>>
>> [1]
>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
>> [2]
>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>>
>> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>
>>> I would appreciate if someone would look at the following PR and get it
>>> to master:
>>>
>>> https://github.com/apache/beam/pull/10413#
>>>
>>> a lot of work needs to follow, but if we have the base already on master
>>> the next layers can follow. As a reminder, this is the base proposal:
>>>
>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>
>>> I've also looked for prior work, and saw that Spark actually has
>>> something comparable:
>>>
>>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>>
>>> but when the options are finished it will be far more powerful as it is
>>> not limited on fields.
>>>
>>>  _/
>>> _/ Alex Van Boxel
>>>
>>>
>>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org> wrote:
>>>
>>>> Using schema types for the metadata values is a nice touch.
>>>>
>>>> Are the options expected to be common across many fields? Perhaps the
>>>> name should be a URN to make it clear to be careful about collisions? (just
>>>> a synonym for "name" in practice, but with different connotation)
>>>>
>>>> I generally like this... but the examples (all but one) are weird
>>>> things that I don't really understand how they are done or who is
>>>> responsible for them.
>>>>
>>>> One way to go is this: if options are maybe not understood by all
>>>> consumers, then they can't really change behavior. Kind of like how URN and
>>>> payload on a composite transform can be ignored and just the expansion used.
>>>>
>>>> Kenn
>>>>
>>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be>
>>>> wrote:
>>>>
>>>>> Hi everyone,
>>>>>
>>>>> I'm proud to announce my first real proposal. The proposal describes
>>>>> Beam Schema Options. This is an extension to the Schema API to add typed
>>>>> meta data to to Rows, Field and Logical Types:
>>>>>
>>>>>
>>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>>
>>>>> To give you some context where this proposal comes from: We've been
>>>>> using dynamic meta driven pipelines for a while, but till now in an
>>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>>
>>>>> The proposal points to 2 pull requests with the implementation, one
>>>>> for the API another for translating proto options to beam options.
>>>>>
>>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>>>>> feedback is welcome.
>>>>>
>>>>>  _/
>>>>> _/ Alex Van Boxel
>>>>>
>>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Reuven Lax <re...@google.com>.
I disagree - I've had several cases where user options on fields are very
useful internally.

A common rationale is to preserve fidelity. For instance, reading protos,
projecting out a few fields, writing protos back out. You want to be able
to nicely map protos to Beam schemas, but also preserve all the extra
metadata on proto fields. This metadata has to carry through on all
intermediate PCollections and schemas, so it makes sense to put it on the
field.

Another example: it provides a nice extension point for annotation
extensions to a field. These are often things like Optional or Taint
markings that don't change the semantic interpretation of the type (so
shouldn't be a logical type), but do provide extra information about the
field.

Reuven

On Fri, Feb 7, 2020 at 8:54 AM Brian Hulette <bh...@google.com> wrote:

> I'm not sure this belongs directly on schemas. I've had trouble
> reconciling that opinion, since the idea does seem very useful, and in fact
> I'm interested in using it myself. I think I've figured out my concern -
> what I really want is options for a (maybe portable) Table.
>
> As I indicated in a comment in the doc [1] I still think all of the
> examples you've described only apply to IOs. To be clear, what I mean is
> that all of the examples either
> 1) modify the behavior of the external system the IO is interfacing with
> (specify partitioning, indexing, etc..), or
> 2) define some transformation that should be done to the data adjacent to
> the IO (after an Input or before an Output) in Beam
>
> (1) Is the sort of thing you described in the IO section [2] (aside from
> the PubSub example I added, since that's describing a transformation to do
> in Beam)
> I would argue that all of the other examples fall under (2) - data
> validation, adding computed columns, encryption, etc... are things that can
> be done in a transform
>
> I think we can make an analogy to a traditional database here:
> schema-aware Beam IOs are like Tables in a database, other PCollections are
> like intermediate results in a query. In a database, Tables can be defined
> with some DDL and have schema-level or column-level options that change
> system behavior, but intermediate results have no such capability.
>
>
> Another point I think is worth discussing: is there value in making these
> options portable?
> As it's currently defined I'm not sure there is - everything could be done
> within a single SDK. However, portable options on a portable table could be
> very powerful, since it could be used to configure cross-language IOs,
> perhaps with something like https://s.apache.org/xlang-table-provider/
>
> [1]
> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
> [2]
> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt
>
> On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>
>> I would appreciate if someone would look at the following PR and get it
>> to master:
>>
>> https://github.com/apache/beam/pull/10413#
>>
>> a lot of work needs to follow, but if we have the base already on master
>> the next layers can follow. As a reminder, this is the base proposal:
>>
>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>
>> I've also looked for prior work, and saw that Spark actually has
>> something comparable:
>>
>> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>>
>> but when the options are finished it will be far more powerful as it is
>> not limited on fields.
>>
>>  _/
>> _/ Alex Van Boxel
>>
>>
>> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org> wrote:
>>
>>> Using schema types for the metadata values is a nice touch.
>>>
>>> Are the options expected to be common across many fields? Perhaps the
>>> name should be a URN to make it clear to be careful about collisions? (just
>>> a synonym for "name" in practice, but with different connotation)
>>>
>>> I generally like this... but the examples (all but one) are weird things
>>> that I don't really understand how they are done or who is responsible for
>>> them.
>>>
>>> One way to go is this: if options are maybe not understood by all
>>> consumers, then they can't really change behavior. Kind of like how URN and
>>> payload on a composite transform can be ignored and just the expansion used.
>>>
>>> Kenn
>>>
>>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>>
>>>> Hi everyone,
>>>>
>>>> I'm proud to announce my first real proposal. The proposal describes
>>>> Beam Schema Options. This is an extension to the Schema API to add typed
>>>> meta data to to Rows, Field and Logical Types:
>>>>
>>>>
>>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>>
>>>> To give you some context where this proposal comes from: We've been
>>>> using dynamic meta driven pipelines for a while, but till now in an
>>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>>
>>>> The proposal points to 2 pull requests with the implementation, one for
>>>> the API another for translating proto options to beam options.
>>>>
>>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>>>> feedback is welcome.
>>>>
>>>>  _/
>>>> _/ Alex Van Boxel
>>>>
>>>

Re: [PROPOSAL] Beam Schema Options

Posted by Brian Hulette <bh...@google.com>.
I'm not sure this belongs directly on schemas. I've had trouble reconciling
that opinion, since the idea does seem very useful, and in fact I'm
interested in using it myself. I think I've figured out my concern - what I
really want is options for a (maybe portable) Table.

As I indicated in a comment in the doc [1] I still think all of the
examples you've described only apply to IOs. To be clear, what I mean is
that all of the examples either
1) modify the behavior of the external system the IO is interfacing with
(specify partitioning, indexing, etc..), or
2) define some transformation that should be done to the data adjacent to
the IO (after an Input or before an Output) in Beam

(1) Is the sort of thing you described in the IO section [2] (aside from
the PubSub example I added, since that's describing a transformation to do
in Beam)
I would argue that all of the other examples fall under (2) - data
validation, adding computed columns, encryption, etc... are things that can
be done in a transform

I think we can make an analogy to a traditional database here: schema-aware
Beam IOs are like Tables in a database, other PCollections are like
intermediate results in a query. In a database, Tables can be defined with
some DDL and have schema-level or column-level options that change
system behavior, but intermediate results have no such capability.


Another point I think is worth discussing: is there value in making these
options portable?
As it's currently defined I'm not sure there is - everything could be done
within a single SDK. However, portable options on a portable table could be
very powerful, since it could be used to configure cross-language IOs,
perhaps with something like https://s.apache.org/xlang-table-provider/

[1]
https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?disco=AAAAI54si4k
[2]
https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit#heading=h.8sjt9ax55hmt

On Wed, Feb 5, 2020, 4:17 AM Alex Van Boxel <al...@vanboxel.be> wrote:

> I would appreciate if someone would look at the following PR and get it to
> master:
>
> https://github.com/apache/beam/pull/10413#
>
> a lot of work needs to follow, but if we have the base already on master
> the next layers can follow. As a reminder, this is the base proposal:
>
> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>
> I've also looked for prior work, and saw that Spark actually has something
> comparable:
>
> https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Row.html
>
> but when the options are finished it will be far more powerful as it is
> not limited on fields.
>
>  _/
> _/ Alex Van Boxel
>
>
> On Wed, Jan 29, 2020 at 4:55 AM Kenneth Knowles <ke...@apache.org> wrote:
>
>> Using schema types for the metadata values is a nice touch.
>>
>> Are the options expected to be common across many fields? Perhaps the
>> name should be a URN to make it clear to be careful about collisions? (just
>> a synonym for "name" in practice, but with different connotation)
>>
>> I generally like this... but the examples (all but one) are weird things
>> that I don't really understand how they are done or who is responsible for
>> them.
>>
>> One way to go is this: if options are maybe not understood by all
>> consumers, then they can't really change behavior. Kind of like how URN and
>> payload on a composite transform can be ignored and just the expansion used.
>>
>> Kenn
>>
>> On Sun, Jan 26, 2020 at 8:27 AM Alex Van Boxel <al...@vanboxel.be> wrote:
>>
>>> Hi everyone,
>>>
>>> I'm proud to announce my first real proposal. The proposal describes
>>> Beam Schema Options. This is an extension to the Schema API to add typed
>>> meta data to to Rows, Field and Logical Types:
>>>
>>>
>>> https://docs.google.com/document/d/1yCCRU5pViVQIO8-YAb66VRh3I-kl0F7bMez616tgM8Q/edit?usp=sharing
>>>
>>> To give you some context where this proposal comes from: We've been
>>> using dynamic meta driven pipelines for a while, but till now in an
>>> awkward and hacky way (see my talks at the previous Beam Summits). This
>>> proposal would bring a good way to work with metadata on the metadata :-).
>>>
>>> The proposal points to 2 pull requests with the implementation, one for
>>> the API another for translating proto options to beam options.
>>>
>>> Thanks to Brian Hulette and Reuven Lax for the initial feedback. All
>>> feedback is welcome.
>>>
>>>  _/
>>> _/ Alex Van Boxel
>>>
>>