You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "shanielh (via GitHub)" <gi...@apache.org> on 2024/07/21 10:00:25 UTC

[PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

shanielh opened a new pull request, #10736:
URL: https://github.com/apache/iceberg/pull/10736

   This may be used in cases where we want to add a partition spec but not set the new partition spec as default.
   
   For example, if I want to make sure that there's an unpartitioned spec since I might want to commit specific data to it in some cases, I would first validate that there's an unpartition spec in the table, and if there isn't, I would try to add the unpartitioned spec but not set it as the new default partition spec


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2246992983

   > This seems reasonable but we do need to add some tests to TestUpdatePartitionSpec to validate the behavior
   
   I had to add the spec to TestTableUpdatePartitionSpec since that's the only one that actually commit the spec to the table, PLMK if there's anything else I need to do for this to get merged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, API: Add addNonDefaultSpec to UpdatePartitionSpec to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2260542383

   > Overall LGTM, as @RussellSpitzer mentioned you'll need to fix RevAPI. Also @RussellSpitzer not sure if you saw the naming change to make the API called `addNonDefaultSpec` , just want to make sure you're also good with that!
   
   Fixed, thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, API: Add addNonDefaultSpec to UpdatePartitionSpec to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer merged PR #10736:
URL: https://github.com/apache/iceberg/pull/10736


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2244231366

   > > > My big question here is what is the value of adding the Spec before you are ready to write data?
   > 
   > > 
   > 
   > > I don't think it matters whether I add the spec just before writing to it or prior. But I wouldn't like to set it as the new default.
   > 
   > 
   > 
   > Wouldn't that mean we would want to modify the write APIs? Isn't that essentially just an engine decision?
   
   The write APIs already support that. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2249962904

   Hi, I've applied the changes you suggested within a new fixup commit, please review and let me know when it's good to squash and rebase.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2256785593

   > Overall LGTM, as @RussellSpitzer mentioned you'll need to fix RevAPI. Also @RussellSpitzer not sure if you saw the naming change to make the API called `addNonDefaultSpec` , just want to make sure you're also good with that!
   
   A rose by any other name :) still +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2243447797

   > My big question here is what is the value of adding the Spec before you are ready to write data?
   
   I don't think it matters whether I add the spec just before writing to it or prior. But I wouldn't like to set it as the new default. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, API: Add addNonDefaultSpec to UpdatePartitionSpec to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2268068867

   Thanks @shanielh for the PR, and @amogh-jahagirdar for Reviewing


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2243841844

   > > My big question here is what is the value of adding the Spec before you are ready to write data?
   > 
   > I don't think it matters whether I add the spec just before writing to it or prior. But I wouldn't like to set it as the new default.
   
   Wouldn't that mean we would want to modify the write APIs? Isn't that essentially just an engine decision?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2245887424

   Got it, Ok let me take a closer look at this


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2243378858

   My big question here is what is the value of adding the Spec before you are ready to write data?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#discussion_r1690448386


##########
api/src/main/java/org/apache/iceberg/UpdatePartitionSpec.java:
##########
@@ -122,4 +122,13 @@ public interface UpdatePartitionSpec extends PendingUpdate<PartitionSpec> {
    *     change conflicts with other additions, removals, or renames.
    */
   UpdatePartitionSpec renameField(String name, String newName);
+
+  /**
+   * Sets whether the new partition spec will be set as the default partition spec for the table,
+   * the default behavior is to do so.
+   *
+   * @param value whether to set the new partition spec as default
+   * @return this for method chaining
+   */
+  UpdatePartitionSpec setAsDefault(Boolean value);

Review Comment:
   I understand the intent and it's reasonable imo (don't think there's any other API where adding this would make sense). Typically we try avoid adding boolean APIs but to facilitate this case, it may be unavoidable. I'd like to think through more alternatives though.
   
   On another note, at minimum I think this should be made a primitive boolean named `setAsDefaultSpec` (same with the API name imo)? 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on code in PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#discussion_r1690468371


##########
api/src/main/java/org/apache/iceberg/UpdatePartitionSpec.java:
##########
@@ -122,4 +122,13 @@ public interface UpdatePartitionSpec extends PendingUpdate<PartitionSpec> {
    *     change conflicts with other additions, removals, or renames.
    */
   UpdatePartitionSpec renameField(String name, String newName);
+
+  /**
+   * Sets whether the new partition spec will be set as the default partition spec for the table,
+   * the default behavior is to do so.
+   *
+   * @param value whether to set the new partition spec as default
+   * @return this for method chaining
+   */
+  UpdatePartitionSpec setAsDefault(Boolean value);

Review Comment:
   we could do a no arg method instead something like 
   
   notDefault()



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#discussion_r1690525854


##########
api/src/main/java/org/apache/iceberg/UpdatePartitionSpec.java:
##########
@@ -122,4 +122,13 @@ public interface UpdatePartitionSpec extends PendingUpdate<PartitionSpec> {
    *     change conflicts with other additions, removals, or renames.
    */
   UpdatePartitionSpec renameField(String name, String newName);
+
+  /**
+   * Sets whether the new partition spec will be set as the default partition spec for the table,
+   * the default behavior is to do so.
+   *
+   * @param value whether to set the new partition spec as default
+   * @return this for method chaining
+   */
+  UpdatePartitionSpec setAsDefault(Boolean value);

Review Comment:
   Yeah couldn’t think of a good name for a no arg method so I discarded it initially but another one came to mind: addWithoutSettingCurrent (maybe a bit verbose) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, API: Add addNonDefaultSpec to UpdatePartitionSpec to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2268067745

   @shanielh In general we want to wait extra time on API module changes since we are committing the project to support this new API for ever. That said I think we've had this open long enough so I'll merge today.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, API: Add addNonDefaultSpec to UpdatePartitionSpec to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2267354955

   @RussellSpitzer, @amogh-jahagirdar Any chance to merge this? All checks have passed and two approvals 😄 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#discussion_r1690457935


##########
core/src/main/java/org/apache/iceberg/BaseUpdatePartitionSpec.java:
##########
@@ -327,7 +336,12 @@ public PartitionSpec apply() {
 
   @Override
   public void commit() {
-    TableMetadata update = base.updatePartitionSpec(apply());
+    TableMetadata update;
+    if (this.setAsDefault) {

Review Comment:
   typically in the project, `this` is only used when writing to the field. Here we could just reference `setAsDefault`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#discussion_r1693722945


##########
api/src/main/java/org/apache/iceberg/UpdatePartitionSpec.java:
##########
@@ -122,4 +122,12 @@ public interface UpdatePartitionSpec extends PendingUpdate<PartitionSpec> {
    *     change conflicts with other additions, removals, or renames.
    */
   UpdatePartitionSpec renameField(String name, String newName);
+
+  /**
+   * Sets that the new partition spec will be NOT set as the default partition spec for the table,
+   * the default behavior is to do so.
+   *
+   * @return this for method chaining
+   */
+  UpdatePartitionSpec notDefault();

Review Comment:
   Could we call this `addNonDefaultSpec` or `addInactiveSpec` cc @RussellSpitzer @shanielh? 
   
   When I was going through the test code the API name felt a bit odd (the heuristic I try and aim for is does it sound right when speaking as a sentence). 
   
   ```
    table.updateSpec().addField("id").addNonDefaultSpec().commit();
   ```
   
   reads more clear to me since it's more clear what the action is ("adding"), and what non-default is referring to ("spec")
   
   inactive maybe a bit more extreme but technically it is not the active table spec if it's added, since every write to the table should just ignore that spec until it is made active.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "shanielh (via GitHub)" <gi...@apache.org>.
shanielh commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2253744447

   > Ah just saw/remembered [#10736 (comment)](https://github.com/apache/iceberg/pull/10736#issuecomment-2244231366), the write APIs Iceberg exposes allow passing in a given spec ID. So you're not really looking to set the spec as current but rather just leverage the existence of the spec in the write APIs. That's reasonable.
   > 
   > Cool, I think I'd still advocate for a different method name. [#10736 (comment)](https://github.com/apache/iceberg/pull/10736#discussion_r1693722945)
   > 
   > After that, I think the PR looks good to me.
   
   Ok, I've modified the method name and squashed all commits into one.
   
   Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] UpdatePartitionSpec: Added ability to not set the new partition spec as default [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on PR #10736:
URL: https://github.com/apache/iceberg/pull/10736#issuecomment-2256533305

   Revapi broken (as expected) please fix


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org