Skip to content

Conversation

@ayushtkn
Copy link
Member

What changes were proposed in this pull request?

Add support for replace tag for iceberg tables

Why are the changes needed?

Better usability

Does this PR introduce any user-facing change?

Yes, they can replace tags in iceberg tables

Is the change a dependency upgrade?

No

How was this patch tested?

UT

Copy link
Contributor

@zhangbutao zhangbutao left a comment

Choose a reason for hiding this comment

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

It was good overall. Only some comments about code organization optimization. :)

long targetSnapshot = replaceTagRefSpec.getTargetSnapshot();
LOG.info("Replacing tag {} with snapshot {} on iceberg table {}", sourceTag, targetSnapshot, table.name());
ManageSnapshots manageSnapshots = table.manageSnapshots().replaceTag(sourceTag, targetSnapshot);
IcebergBranchExec.setOptionalReplaceParams(replaceTagRefSpec, manageSnapshots, sourceTag);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this line want to reuse IcebergBranchExec code to reduce code duplication. But my original thought was to keep Branch and Tag operation separate.

I am not aginst doing this as Branch and Tag operation indeed have many similar code.

  1. Maybe we can merge the two IcebergBranchExec & IcebergTagExec into one class.
  2. Or we can extract the common codes and put it into the utility class.
    This optimization can be done once branch&tag feature are all done in the future. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

If I got you right, I will do [1] in the next iter & merge the classes as suggested as IcebergSnapshotRefExec

iterable = newOrcIterable(inputFile, task, readSchema);
break;
case PARQUET:
if (inputFile instanceof HadoopInputFile) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the change meaning? Is it related the replace tag?

Copy link
Member Author

Choose a reason for hiding this comment

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

ohh shit, was something else running internally & it got added accidentally in this, I will remove in the next iter

}

@Test
public void testReplaceTag() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have TestHiveIcebergTagOperation & TestHiveIcebergBranchOperation. Should we put the branch&tag operation into there?

import org.apache.hadoop.hive.ql.parse.SemanticException;

@DDLSemanticAnalyzerFactory.DDLType(types = HiveParser.TOK_ALTERTABLE_REPLACE_TAG)
public class AlterTableReplaceTagRefAnalyzer extends AbstractAlterTableAnalyzer {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good if we can merge AlterTableReplaceTagRefAnalyzer & AlterTableReplaceBranchRefAnalyzer into one class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have attempted to merge both in the next iter.

ALTERTABLE_REPLACESNAPSHOTREF,
ALTERTABLE_CREATETAG,
ALTERTABLE_DROPTAG,
ALTERTABLE_REPLACETAG,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

nopes, removed

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.filecache.DistributedCache;
import org.apache.hadoop.fs.CommonPathCapabilities;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need this import...

op2Priv.put(HiveOperationType.ALTERTABLE_REPLACEBRANCH,
op2Priv.put(HiveOperationType.ALTERTABLE_REPLACESNAPSHOTREF,
PrivRequirement.newIOPrivRequirement(OWNER_PRIV_AR, OWNER_PRIV_AR));
op2Priv.put(HiveOperationType.ALTERTABLE_REPLACETAG,
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too. Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

nopes, removed

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 5, 2024

Quality Gate Passed Quality Gate passed

Issues
10 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@zhangbutao zhangbutao left a comment

Choose a reason for hiding this comment

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

LGTM +1

@ayushtkn ayushtkn merged commit 8415527 into apache:master May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants