code: protected String resolveNamespace(String namespace, String name,
                                      @Nullable URI location) {
      if (getMetaStoreUtil().exists(namespace, name)) {
        return namespace;
      }
      try {
        DatasetDescriptor descriptor = HiveUtils.descriptorForTable(
            conf, getMetaStoreUtil().getTable(URIBuilder.NAMESPACE_DEFAULT, name));
        URI expectedLocation = location;
        if (location == null) {
          expectedLocation = expectedLocation(namespace, name);
        }
        if ((expectedLocation == null) ||
            pathsEquivalent(expectedLocation, descriptor.getLocation())) {
          // table in the default db has the location that would have been used
          return URIBuilder.NAMESPACE_DEFAULT;
        }
        // fall through and return null
      } catch (DatasetNotFoundException e) {
        // fall through and return null
      }
      return null;
    }
docs: Checks whether the Hive table {@code namespace.name} exists or if
  {@code default.name} exists and should be used.
  
  @param namespace the requested namespace
  @param name the table name
  @param location location that should match or null to check the default
  @return if namespace.name exists, namespace. if not and default.name
  exists, then default. {@code null} otherwise.