[ 
https://issues.apache.org/jira/browse/PHOENIX-6847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17649901#comment-17649901
 ] 

Rushabh Shah edited comment on PHOENIX-6847 at 12/20/22 6:45 PM:
-----------------------------------------------------------------

>  I agree that novice users or applications can inadvertently call it multiple 
> times. But I think that is no different than one calling 
> PhoenixRuntime.getTableNoCache(..) multiple times.

If they are calling PhoenixRuntime.getTableNoCache then they are making a 
conscious decision that this table will NOT be cached since the method name is 
getTableNoCache. So this is not the same as users calling DatabaseMetaData 
where they are unaware that this is making call to SYSCAT on every invocation.

 

> I am all for easy and performant API (aside from the JDBC API) which is 
> concise and does not expose too much of our internals.

If you don't want to expose the internal details like PTable then I am ok with 
this API where we return boolean. This way we won't expose PTable object.
{noformat}
public boolean viewExists(String schemaName, String viewName, String tenantID);
{noformat}
[~jisaac] [~stoty] [~gjacoby]  WDYT?


was (Author: shahrs87):
>  I agree that novice users or applications can inadvertently call it multiple 
> times. But I think that is no different than one calling 
> PhoenixRuntime.getTableNoCache(..) multiple times.

If they are calling PhoenixRuntime.getTableNoCache then they are making a 
conscious decision that this table will NOT be cached since the method name is 
getTableNoCache. So this is not the same as users calling DatabaseMetaData 
where they are unaware that this is making call to SYSCAT on every invocation.

 

> I am all for easy and performant API (aside from the JDBC API) which is 
> concise and does not expose too much of our internals.

If you don't want to expose the internal details like PTable then I am ok with 
this API where we return boolean. This way we won't expose PTable object.
{noformat}
public boolean viewExists(String viewName, String tenantID);
{noformat}
[~jisaac] [~stoty] [~gjacoby]  WDYT?

> Provide a crisp API to check if a view exists.
> ----------------------------------------------
>
>                 Key: PHOENIX-6847
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6847
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Rushabh Shah
>            Priority: Major
>
> Currently customer using phoenix runs the following statements to check if a 
> view exists or not.
> {noformat}
>   public static boolean checkTableViewExists(Connection connection, String 
> schema, String viewName)
>       throws SQLException {
>     DatabaseMetaData meta = connection.getMetaData();
>     ResultSet resultSet = meta.getTables(null, schema, viewName, new String[] 
> {"VIEW"});
>     return resultSet.next();
>   }
> {noformat}
> IMHO this is NOT very user friendly.
> We need to provide either of the 2 APIs
> {noformat}
> public PTable getView(String viewName, String tenantID);  OR 
> public boolean viewExists(String schemaName, String viewName, String 
> tenantID);
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to