Skip to content

Commit

Permalink
Add ability to read session properties from HdfsContext
Browse files Browse the repository at this point in the history
  • Loading branch information
bhhari authored and highker committed Apr 26, 2021
1 parent 130863f commit bb50c29
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class HdfsContext
// true if the table already exist in the metastore, false if the table is about to be created in the current transaction
private final Optional<Boolean> isNewTable;
private final Optional<String> clientInfo;
private final Optional<ConnectorSession> session;

/**
* Table information is expected to be provided when accessing a storage.
Expand All @@ -48,6 +49,7 @@ public HdfsContext(ConnectorIdentity identity)
this.clientInfo = Optional.empty();
this.tablePath = Optional.empty();
this.isNewTable = Optional.empty();
this.session = Optional.empty();
}

/**
Expand Down Expand Up @@ -109,7 +111,7 @@ private HdfsContext(
Optional<String> tablePath,
Optional<Boolean> isNewTable)
{
requireNonNull(session, "session is null");
this.session = Optional.of(requireNonNull(session, "session is null"));
this.identity = requireNonNull(session.getIdentity(), "session.getIdentity() is null");
this.source = requireNonNull(session.getSource(), "session.getSource() is null");
this.queryId = Optional.of(session.getQueryId());
Expand Down Expand Up @@ -160,6 +162,11 @@ public Optional<String> getClientInfo()
return clientInfo;
}

public Optional<ConnectorSession> getSession()
{
return session;
}

@Override
public String toString()
{
Expand All @@ -173,6 +180,7 @@ public String toString()
.add("tablePath", tablePath.orElse(null))
.add("isNewTable", isNewTable.orElse(null))
.add("clientInfo", clientInfo.orElse(null))
.add("session", session.orElse(null))
.toString();
}
}

0 comments on commit bb50c29

Please sign in to comment.