Skip to content

Conversation

@Peng-Lei
Copy link
Contributor

@Peng-Lei Peng-Lei commented Jan 7, 2022

What changes were proposed in this pull request?

Add V2 table build-in properties into V1Table.properties to adapt to V2 command.

Why are the changes needed?

#discuss

Does this PR introduce any user-facing change?

No

How was this patch tested?

Add ut testcase and existed ut testcase.

@github-actions github-actions bot added the SQL label Jan 7, 2022
@Peng-Lei Peng-Lei force-pushed the SPARK-37827 branch 2 times, most recently from 78f65e7 to 6440b16 Compare January 7, 2022 12:01
@Peng-Lei
Copy link
Contributor Author

Peng-Lei commented Jan 7, 2022

@cloud-fan @imback82 @huaxingao Could you take a look? Thank you very much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, isn't PROP_EXTERNAL included in TABLE_RESERVED_PROPERTIES?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original code

val tableProperties = properties
      .filterKeys(!_.startsWith(VIEW_PREFIX))
      .toSeq.sortBy(_._1)
      .map(p => p._1 + "=" + p._2).mkString("[", ", ", "]")
...
if (properties.nonEmpty) map.put("Table Properties", tableProperties) // Here I think it is more reasonable to judge the empty of tablePropertie, but it is string "[]", not empty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should generate these v2 table properties here, instead of when creating the table. It's a breaking change to generate v2 properties when creating tables, as it changes what to store in the metastore, which may have unknown consequences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much. I try do it. In fact, officially because store these v2 table properties into metastore when create table, I spent a lot of time looking for failed use cases and trying to fix. It is indeed a breaking change to generate v2 properties when creating tables and store them. Thank you for your reminder very much. @cloud-fan

@Peng-Lei Peng-Lei force-pushed the SPARK-37827 branch 2 times, most recently from 5139d05 to 36f387c Compare January 10, 2022 12:23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

if (...) {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@cloud-fan cloud-fan Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Map(TableCatalog.PROP_OWNER -> Utils.getCurrentUserName())
Some(TableCatalog.PROP_OWNER -> v1Table.owner)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unreliable. I'd test assert(properties.containsKey(TableCatalog.PROP_OWNER))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the empty properties check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, can we keep this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in d7d31d0 Jan 12, 2022
dchvn pushed a commit to dchvn/spark that referenced this pull request Jan 19, 2022
…e.propertie to adapt to V2 command

### What changes were proposed in this pull request?
Add V2 table build-in properties into V1Table.properties to adapt to V2 command.

### Why are the changes needed?
[#discuss](apache#34773 (comment))

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Add ut testcase and existed ut testcase.

Closes apache#35131 from Peng-Lei/SPARK-37827.

Authored-by: PengLei <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants