fdb-record-layer icon indicating copy to clipboard operation
fdb-record-layer copied to clipboard

Resolves #1847: TypeReposistory does not allow for named enums

Open alecgrieser opened this issue 2 years ago • 8 comments

This adds a "name" field to the enum type used by the type repository so that the user can associate a name for the enum type. When a user later looks at field, the enum type can then be looked up via this name.

This resolves #1847.

alecgrieser avatar Sep 20 '22 22:09 alecgrieser

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: eed16dc905648551372a8d0d3c104a77e60c0ba8
  • Duration 0:15:44
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Sep 20 '22 23:09 foundationdb-ci

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: eed16dc905648551372a8d0d3c104a77e60c0ba8
  • Duration 0:16:22
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Sep 20 '22 23:09 foundationdb-ci

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: 656b4274de0b116f08e70e337c2dcfa3f95c14d4
  • Duration 0:16:10
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Sep 20 '22 23:09 foundationdb-ci

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: 656b4274de0b116f08e70e337c2dcfa3f95c14d4
  • Duration 0:16:46
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Sep 20 '22 23:09 foundationdb-ci

I'm not sure I have too many opinions on the parts of this PR around the equals and hashCode implementations, and if we want to change those to be more consistent with structural equality, we can do that. I guess, in particular, if we wanted to make this to use a more "structural equality" approach, I can make the .equals method on the enum type exclude the name, and then two enum types will be considered equal if and only if they have the same fields.

I think it sort of depends on whether enums are considered by the type system to be more like strings that have a restricted set of values (and have a special ordering property), or if enums are more "their own thing", and we really do want two enums with the same values but different names to be different enums. I think I prefer the latter (and that they are different from structs in that way), but I could see it going either way.

In any case, my actual goal with this change was more around making sure that one could create an Enum type that could set a user-defined name, which is necessary for use for DDL use cases (if not query use cases).

alecgrieser avatar Oct 04 '22 09:10 alecgrieser

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: bb3c12fbea4425a2acd1ce913700eac5f670d1db
  • Duration 0:15:15
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 04 '22 10:10 foundationdb-ci

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: bb3c12fbea4425a2acd1ce913700eac5f670d1db
  • Duration 0:15:36
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 04 '22 10:10 foundationdb-ci

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: a63ebc5087104f0ae4d9ff130c92a61abf0570de
  • Duration 0:15:32
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 19 '22 10:10 foundationdb-ci

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: a63ebc5087104f0ae4d9ff130c92a61abf0570de
  • Duration 0:16:21
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 19 '22 10:10 foundationdb-ci

Okay, this PR should now set enums up to be similar to records, in that they have a name field, but that is not used when constructing the enum unless explicitly set by the user using a somewhat special constructor. The name field is also not included in the equals and hashCode methods, so two enums with identical fields should compare equally. However, a user who uses the new constructor can set the name if they need to keep track of it (for referential reasons, say).

alecgrieser avatar Oct 19 '22 15:10 alecgrieser

Let's go ahead and merge this PR. This is localised enough that we can get back to the discussion and add further modifications down the line if need be.

arnaud-lacurie avatar Oct 26 '22 09:10 arnaud-lacurie

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: 15fcd3c57c1e0f62d236979690176cf4736796b1
  • Duration 0:15:31
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 26 '22 17:10 foundationdb-ci

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: 15fcd3c57c1e0f62d236979690176cf4736796b1
  • Duration 0:16:26
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 26 '22 17:10 foundationdb-ci

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: 354c1ace08e68caad002e0633c4abb0cbd594739
  • Duration 0:15:30
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 27 '22 08:10 foundationdb-ci

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: 354c1ace08e68caad002e0633c4abb0cbd594739
  • Duration 0:15:57
  • Result: :white_check_mark: SUCCEEDED
  • Error: N/A
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

foundationdb-ci avatar Oct 27 '22 08:10 foundationdb-ci