Vova,

I am not sure I am qualified to propose such a design, but I would like to
fully understand your proposal. Can you please suggest how a user would use
an enum-based query, after having specified an enum in the CREATE TABLE
command, as you suggested?

D.

On Tue, Apr 25, 2017 at 3:17 PM, Vladimir Ozerov <voze...@gridgain.com>
wrote:

> Dima, Sergi,
>
> Please propose how are you going to work with enums from SQL perspective
> without registering them in advance. I already shared my thoughts and
> provided two examples how this is achieved in MySQL and PostgreSQL.
>
> On Tue, Apr 25, 2017 at 3:06 PM, Dmitriy Setrakyan <dsetrak...@apache.org>
> wrote:
>
> > Vladimir, can you please share your thoughts here?
> >
> > On Mon, Apr 24, 2017 at 5:21 PM, Sergi Vladykin <
> sergi.vlady...@gmail.com>
> > wrote:
> >
> > > I agree with Dmitriy, it is preferable to have this enum registration
> > > optional. It will be a better user experience.
> > >
> > > Why do we "inevitably" need it?
> > >
> > > Sergi
> > >
> > > 2017-04-24 17:02 GMT+03:00 Vladimir Ozerov <voze...@gridgain.com>:
> > >
> > > > Dima,
> > > >
> > > > No. It is normal (and inevitably) practice to register enums before
> > they
> > > > are used.
> > > >
> > > > This is how enum is created in MySQL:
> > > >
> > > > CREATE TABLE shirts (
> > > >     name VARCHAR(40),
> > > >     size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
> > > > );
> > > >
> > > > And in PostgreSQL:
> > > >
> > > > CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
> > > > CREATE TABLE person (
> > > >     name text,
> > > >     current_mood mood
> > > > );
> > > >
> > > > We will do the same at some point. That is, in future users will
> > register
> > > > enums from SQL, not from native API or configuration.
> > > >
> > > > Vladimir.
> > > >
> > > > On Mon, Apr 24, 2017 at 4:37 PM, Dmitriy Setrakyan <
> > > dsetrak...@apache.org>
> > > > wrote:
> > > >
> > > > > Vladimir,
> > > > >
> > > > > I would really like to avoid special registration of Enums. Can you
> > > find
> > > > a
> > > > > way to handle it automatically?
> > > > >
> > > > > D.
> > > > >
> > > > > On Mon, Apr 24, 2017 at 6:33 AM, Vladimir Ozerov <
> > voze...@gridgain.com
> > > >
> > > > > wrote:
> > > > >
> > > > > > Sorry, looks like I mismanaged tickets in JIRA. In fact, we
> > > implemented
> > > > > H2
> > > > > > part, but Ignite's part is not ready yet and is managed in
> > > IGNITE-4575
> > > > > [1].
> > > > > > Ticket you mentioned was an umbrella.
> > > > > >
> > > > > > [1] https://issues.apache.org/jira/browse/IGNITE-4575
> > > > > >
> > > > > > On Mon, Apr 24, 2017 at 4:28 PM, Dmitriy Setrakyan <
> > > > > dsetrak...@apache.org>
> > > > > > wrote:
> > > > > >
> > > > > > > Vladimir,
> > > > > > >
> > > > > > > I am very confused. I thought we already had resolved this
> issue
> > in
> > > > > this
> > > > > > > ticket:
> > > > > > > https://issues.apache.org/jira/browse/IGNITE-3595
> > > > > > >
> > > > > > > Can you clarify?
> > > > > > >
> > > > > > > D.
> > > > > > >
> > > > > > > On Mon, Apr 24, 2017 at 5:58 AM, Vladimir Ozerov <
> > > > voze...@gridgain.com
> > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Igniters,
> > > > > > > >
> > > > > > > > Currently we have limited support of binary enums. The main
> > > problem
> > > > > is
> > > > > > > that
> > > > > > > > we do not store any metadata about enum names. For this
> reason
> > it
> > > > is
> > > > > > > > impossible to use enums in SQL even though H2 already
> supports
> > it
> > > > > [1].
> > > > > > We
> > > > > > > > need to improve enum metadata support and provide some
> > additional
> > > > API
> > > > > > to
> > > > > > > > register new enums in runtime.
> > > > > > > >
> > > > > > > > Proposed API:
> > > > > > > >
> > > > > > > > 1) Enum mappings can be defined statically in
> > > > > BinaryTypeConfiguration:
> > > > > > > >
> > > > > > > > class BinaryTypeConfiguration {
> > > > > > > >     boolean isEnum;                  // Old method
> > > > > > > >     *Map<String, Integer> enumValues;* // New method
> > > > > > > > }
> > > > > > > >
> > > > > > > > 2) New enum could be registered through IgniteBinary (e.g. we
> > > will
> > > > > use
> > > > > > it
> > > > > > > > if enum is defined in CREATE TABLE statement). Elso it would
> be
> > > > > > possible
> > > > > > > to
> > > > > > > > build enum using only name.
> > > > > > > >
> > > > > > > > interface IgniteBinary {
> > > > > > > >     BinaryObject buildEnum(String typeName, int ordinal);
> > > > > > //
> > > > > > > > Old
> > > > > > > >     *BinaryObject buildEnum(String typeName, String name); *
> > > > > > >  //
> > > > > > > > New
> > > > > > > >
> > > > > > > >     *BinaryType defineEnum(String typeName, Map<String,
> > Integer>
> > > > > > vals);*
> > > > > > > //
> > > > > > > > New
> > > > > > > > }
> > > > > > > >
> > > > > > > > 3) BinaryObject will have new method "enumName":
> > > > > > > >
> > > > > > > > interface BinaryObject {
> > > > > > > >     enumOrdinal();     // Old
> > > > > > > >     *String enumName();* // New
> > > > > > > > }
> > > > > > > >
> > > > > > > > 4) It would be possible to get the list of known values from
> > > > > > BinaryType:
> > > > > > > >
> > > > > > > > interface BinaryType {
> > > > > > > >     boolean isEnum();                      // Old
> > > > > > > >     *Collection<BinaryObject> enumValues();* // New
> > > > > > > > }
> > > > > > > >
> > > > > > > > Thoughts?
> > > > > > > >
> > > > > > > > Vladimir.
> > > > > > > >
> > > > > > > > [1] https://github.com/h2database/
> h2database/pull/487/commits
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to