devoopsman45 commented on code in PR #102:
URL: https://github.com/apache/datafusion-java/pull/102#discussion_r3370519300


##########
core/src/main/java/org/apache/datafusion/SessionContext.java:
##########
@@ -601,6 +601,43 @@ private static byte[] serializeSchemaIpc(Schema schema) {
     return baos.toByteArray();
   }
 
+  /**
+   * Returns {@code true} if a table with the given name is registered in this 
session.
+   *
+   * <p>This is the Java counterpart to DataFusion's Rust {@code 
SessionContext::table_exist}.
+   *
+   * @throws IllegalStateException if this context is closed.
+   */
+  public boolean tableExists(String name) {
+    checkOpen();
+    if (name == null) {
+      throw new IllegalArgumentException("tableExists name must be non-null");
+    }
+    return tableExists(nativeHandle, name);
+  }
+
+  /**
+   * Removes the table with the given name from this session. Does nothing if 
no table with that
+   * name is registered.
+   *
+   * <p>This is the Java counterpart to DataFusion's Rust {@code 
SessionContext::deregister_table}.
+   *
+   * @throws IllegalStateException if this context is closed.
+   */
+  public void deregisterTable(String name) {
+    checkOpen();
+    if (name == null) {
+      throw new IllegalArgumentException("deregisterTable name must be 
non-null");
+    }
+    deregisterTable(nativeHandle, name);
+  }
+
+  private void checkOpen() {
+    if (nativeHandle == 0) {
+      throw new IllegalStateException("SessionContext is closed");

Review Comment:
   Thanks for the feedback. This file in general has a throw on closed sort of 
pattern. If optional is returned, it would force every caller to .orElseThrow() 
paradigm, which seems a bit noisy for private helper.  We can probably do this 
as a seperate enhancement if needed.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to