Skip to content

Commit

Permalink
Merge branch 'metastore-impl' into metastore-tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/src/main/java/io/unitycatalog/server/UnityCatalogServer.java
  • Loading branch information
vikrantpuppala committed Oct 14, 2024
2 parents 26c5662 + 632b47b commit b8d08db
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 63 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/lint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ jobs:
- name: Run lint check
run: |
(cd ui && yarn install && yarn test:format)
java-fmt:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Run Java format check
run: |
build/sbt javafmtCheck
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public void start() {
transcodePort,
ar -> {
if (ar.succeeded()) {
LOGGER.info("URL transcoder started on port " + transcodePort);
LOGGER.info("URL transcoder started on port {}", transcodePort);
} else {
LOGGER.info("Failed to start URL transcoder: " + ar.cause());
LOGGER.info("Failed to start URL transcoder: {}", String.valueOf(ar.cause()));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.unitycatalog.server.exception.ErrorCode;
import io.unitycatalog.server.exception.ExceptionHandlingDecorator;
import io.unitycatalog.server.exception.GlobalExceptionHandler;
import io.unitycatalog.server.utils.ServerProperties;
import io.unitycatalog.server.persist.MetastoreRepository;
import io.unitycatalog.server.security.SecurityConfiguration;
import io.unitycatalog.server.security.SecurityContext;
Expand All @@ -33,6 +32,7 @@
import io.unitycatalog.server.service.iceberg.TableConfigService;
import io.unitycatalog.server.utils.OptionParser;
import io.unitycatalog.server.utils.RESTObjectMapper;
import io.unitycatalog.server.utils.ServerProperties;
import io.unitycatalog.server.utils.VersionUtils;
import io.vertx.core.Verticle;
import io.vertx.core.Vertx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public RegisteredModelInfoDAO getRegisteredModelDao(Session session, UUID schema
query.setParameter("schemaId", schemaId);
query.setParameter("name", name);
query.setMaxResults(1);
LOGGER.info("Finding registered model by schemaId: " + schemaId + " and name: " + name);
LOGGER.info("Finding registered model by schemaId: {} and name: {}", schemaId, name);
return query.uniqueResult(); // Returns null if no result is found
}

Expand Down Expand Up @@ -75,8 +75,7 @@ public ModelVersionInfoDAO getModelVersionDao(Session session, UUID modelId, Lon
query.setParameter("registeredModelId", modelId);
query.setParameter("version", version.toString());
query.setMaxResults(1);
LOGGER.info(
"Finding model version by registeredModelId: " + modelId + " and version: " + version);
LOGGER.info("Finding model version by registeredModelId: {} and version: {}", modelId, version);
return query.uniqueResult(); // Returns null if no result is found
}

Expand Down Expand Up @@ -107,7 +106,7 @@ public List<ModelVersionInfoDAO> getModelVersionsDao(
query.setParameter("registeredModelId", registeredModelId);
query.setParameter("token", Long.parseLong(token));
query.setMaxResults(maxResults);
LOGGER.info("Finding model versions by registeredModelId: " + registeredModelId);
LOGGER.info("Finding model versions by registeredModelId: {}", registeredModelId);
return query.getResultList(); // Returns null if no result is found
}

Expand Down Expand Up @@ -136,7 +135,7 @@ public String getNextPageToken(List<ModelVersionInfoDAO> entities, Optional<Inte

/** **************** Registered Model handlers ***************** */
public RegisteredModelInfo getRegisteredModelById(String registeredModelId) {
LOGGER.info("Getting registered model by id: " + registeredModelId);
LOGGER.info("Getting registered model by id: {}", registeredModelId);
try (Session session = SESSION_FACTORY.openSession()) {
session.setDefaultReadOnly(true);
Transaction tx = session.beginTransaction();
Expand Down Expand Up @@ -169,7 +168,7 @@ public RegisteredModelInfo getRegisteredModelById(String registeredModelId) {
}

public RegisteredModelInfo getRegisteredModel(String fullName) {
LOGGER.info("Getting registered model: " + fullName);
LOGGER.info("Getting registered model: {}", fullName);
RegisteredModelInfo registeredModelInfo = null;
try (Session session = SESSION_FACTORY.openSession()) {
session.setDefaultReadOnly(true);
Expand Down Expand Up @@ -224,7 +223,7 @@ public RegisteredModelInfo createRegisteredModel(CreateRegisteredModel createReg
.updatedBy(callerId);
String fullName = getRegisteredModelFullName(registeredModelInfo);
registeredModelInfo.setFullName(fullName);
LOGGER.info("Creating Registered Model: " + fullName);
LOGGER.info("Creating Registered Model: {}", fullName);

Transaction tx;
try (Session session = SESSION_FACTORY.openSession()) {
Expand Down Expand Up @@ -258,10 +257,9 @@ public RegisteredModelInfo createRegisteredModel(CreateRegisteredModel createReg
// UriUtils.deleteStorageLocationPath(storageLocation);
} catch (Exception deleteErr) {
LOGGER.error(
"Unable to delete storage location "
+ storageLocation
+ " during rollback: "
+ deleteErr.getMessage());
"Unable to delete storage location {} during rollback: {}",
storageLocation,
deleteErr.getMessage());
}
tx.rollback();
}
Expand Down Expand Up @@ -325,7 +323,7 @@ public ListRegisteredModelsResponse listRegisteredModels(
.registeredModels(result)
.nextPageToken(nextPageToken);
} else {
LOGGER.info("Listing registered models in " + catalogName.get() + "." + schemaName.get());
LOGGER.info("Listing registered models in {}.{}", catalogName.get(), schemaName.get());
UUID schemaId = RepositoryUtils.getSchemaId(session, catalogName.get(), schemaName.get());
response =
listRegisteredModels(
Expand Down Expand Up @@ -376,7 +374,7 @@ public RegisteredModelInfo updateRegisteredModel(
throw new BaseException(ErrorCode.INVALID_ARGUMENT, "No updated fields defined.");
}

LOGGER.info("Updating Registered Model: " + fullName);
LOGGER.info("Updating Registered Model: {}", fullName);
RegisteredModelInfo registeredModelInfo;
String callerId = IdentityUtils.findPrincipalEmailAddress();

Expand Down Expand Up @@ -439,7 +437,7 @@ public RegisteredModelInfo updateRegisteredModel(
}

public void deleteRegisteredModel(String fullName, boolean force) {
LOGGER.info("Deleting Registered Model: " + fullName);
LOGGER.info("Deleting Registered Model: {}", fullName);
try (Session session = SESSION_FACTORY.openSession()) {
Transaction tx = session.beginTransaction();
String[] parts = fullName.split("\\.");
Expand Down Expand Up @@ -493,7 +491,7 @@ public void deleteRegisteredModel(

/** **************** Model version handlers ***************** */
public ModelVersionInfo getModelVersion(String fullName, long version) {
LOGGER.info("Getting model version: " + fullName + "/" + version);
LOGGER.info("Getting model version: {}/{}", fullName, version);
ModelVersionInfo modelVersionInfo = null;
try (Session session = SESSION_FACTORY.openSession()) {
session.setDefaultReadOnly(true);
Expand Down Expand Up @@ -551,7 +549,7 @@ public ModelVersionInfo createModelVersion(CreateModelVersion createModelVersion
.updatedAt(createTime)
.updatedBy(callerId);
String registeredModelFullName = getRegisteredModelFullName(catalogName, schemaName, modelName);
LOGGER.info("Creating Registered Model: " + registeredModelFullName);
LOGGER.info("Creating Registered Model: {}", registeredModelFullName);

Transaction tx;
try (Session session = SESSION_FACTORY.openSession()) {
Expand Down Expand Up @@ -592,10 +590,9 @@ public ModelVersionInfo createModelVersion(CreateModelVersion createModelVersion
// UriUtils.deleteStorageLocationPath(storageLocation);
} catch (Exception deleteErr) {
LOGGER.error(
"Unable to delete storage location "
+ storageLocation
+ " during rollback: "
+ deleteErr.getMessage());
"Unable to delete storage location {} during rollback: {}",
storageLocation,
deleteErr.getMessage());
}
tx.rollback();
}
Expand All @@ -615,7 +612,7 @@ public ModelVersionInfo createModelVersion(CreateModelVersion createModelVersion

public ListModelVersionsResponse listModelVersions(
String registeredModelFullName, Optional<Integer> maxResults, Optional<String> pageToken) {
LOGGER.info("Listing model versions in " + registeredModelFullName);
LOGGER.info("Listing model versions in {}", registeredModelFullName);
if (maxResults.isPresent() && maxResults.get() < 0) {
throw new BaseException(
ErrorCode.INVALID_ARGUMENT, "maxResults must be greater than or equal to 0");
Expand Down Expand Up @@ -691,7 +688,7 @@ public ModelVersionInfo updateModelVersion(
throw new BaseException(ErrorCode.INVALID_ARGUMENT, "No updated fields defined.");
}

LOGGER.info("Updating Model Version: " + fullName + "/" + version);
LOGGER.info("Updating Model Version: {}/{}", fullName, version);
ModelVersionInfo modelVersionInfo;
String callerId = IdentityUtils.findPrincipalEmailAddress();

Expand Down Expand Up @@ -735,7 +732,7 @@ public ModelVersionInfo updateModelVersion(
}

public void deleteModelVersion(String fullName, Long version) {
LOGGER.info("Deleting model version: " + fullName + "/" + version);
LOGGER.info("Deleting model version: {}/{}", fullName, version);
String[] parts = fullName.split("\\.");
if (parts.length != 3) {
throw new BaseException(
Expand Down Expand Up @@ -782,7 +779,7 @@ public ModelVersionInfo finalizeModelVersion(FinalizeModelVersion finalizeModelV

String fullName = finalizeModelVersion.getFullName();
Long version = finalizeModelVersion.getVersion();
LOGGER.info("Finalize Model Version: " + fullName + "/" + version);
LOGGER.info("Finalize Model Version: {}/{}", fullName, version);
ModelVersionInfo modelVersionInfo;
String callerId = IdentityUtils.findPrincipalEmailAddress();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static TableRepository getInstance() {
}

public TableInfo getTableById(String tableId) {
LOGGER.debug("Getting table by id: " + tableId);
LOGGER.debug("Getting table by id: {}", tableId);
try (Session session = SESSION_FACTORY.openSession()) {
session.setDefaultReadOnly(true);
Transaction tx = session.beginTransaction();
Expand Down Expand Up @@ -73,7 +73,7 @@ public TableInfo getTableById(String tableId) {
}

public TableInfo getTable(String fullName) {
LOGGER.debug("Getting table: " + fullName);
LOGGER.debug("Getting table: {}", fullName);
TableInfo tableInfo = null;
try (Session session = SESSION_FACTORY.openSession()) {
session.setDefaultReadOnly(true);
Expand Down Expand Up @@ -144,7 +144,7 @@ public TableInfo createTable(CreateTable createTable) {
.updatedAt(createTime)
.updatedBy(callerId);
String fullName = getTableFullName(tableInfo);
LOGGER.debug("Creating table: " + fullName);
LOGGER.debug("Creating table: {}", fullName);

Transaction tx;
try (Session session = SESSION_FACTORY.openSession()) {
Expand Down Expand Up @@ -204,7 +204,7 @@ public TableInfoDAO findBySchemaIdAndName(Session session, UUID schemaId, String
Query<TableInfoDAO> query = session.createQuery(hql, TableInfoDAO.class);
query.setParameter("schemaId", schemaId);
query.setParameter("name", name);
LOGGER.debug("Finding table by schemaId: " + schemaId + " and name: " + name);
LOGGER.debug("Finding table by schemaId: {} and name: {}", schemaId, name);
return query.uniqueResult(); // Returns null if no result is found
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.unitycatalog.server.exception.BaseException;
import io.unitycatalog.server.exception.ErrorCode;
import io.unitycatalog.server.utils.Constants;
import io.unitycatalog.server.utils.ServerProperties;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
Expand All @@ -20,8 +21,6 @@
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.stream.Stream;

import io.unitycatalog.server.utils.ServerProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -76,7 +75,7 @@ private static URI createLocalDirectory(Path dirPath) {
// Create the directory
try {
Files.createDirectories(dirPath);
LOGGER.debug("Directory created successfully: " + dirPath);
LOGGER.debug("Directory created successfully: {}", dirPath);
} catch (Exception e) {
throw new BaseException(ErrorCode.INTERNAL, "Failed to create directory: " + dirPath, e);
}
Expand Down Expand Up @@ -151,7 +150,7 @@ private static URI modifyS3Directory(URI parsedUri, boolean createOrDelete) {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(0);
s3Client.putObject(new PutObjectRequest(bucketName, path, emptyContentStream, metadata));
LOGGER.debug("Directory created successfully: " + path);
LOGGER.debug("Directory created successfully: {}", path);
return URI.create(String.format("s3://%s/%s", bucketName, path));
} catch (Exception e) {
throw new BaseException(ErrorCode.INTERNAL, "Failed to create directory: " + path, e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.unitycatalog.server.persist.utils;

import io.unitycatalog.server.persist.dao.*;
import io.unitycatalog.server.utils.ServerProperties;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

import io.unitycatalog.server.utils.ServerProperties;
import lombok.Getter;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.unitycatalog.server.model.AzureUserDelegationSAS;
import io.unitycatalog.server.model.GcpOauthToken;
import io.unitycatalog.server.model.TemporaryCredentials;
import io.unitycatalog.server.utils.ServerProperties;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -21,8 +22,6 @@
import java.util.Comparator;
import java.util.Optional;
import java.util.stream.Stream;

import io.unitycatalog.server.utils.ServerProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -165,7 +164,7 @@ private static URI updateLocalDirectory(URI parsedUri, Operation op) throws IOEx
// Create the directory
try {
Files.createDirectories(dirPath);
LOGGER.debug("Directory created successfully: " + dirPath);
LOGGER.debug("Directory created successfully: {}", dirPath);
} catch (Exception e) {
throw new BaseException(ErrorCode.INTERNAL, "Failed to create directory: " + dirPath, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import io.unitycatalog.server.exception.GlobalExceptionHandler;
import io.unitycatalog.server.exception.OAuthInvalidRequestException;
import io.unitycatalog.server.persist.UserRepository;
import io.unitycatalog.server.utils.ServerProperties;
import io.unitycatalog.server.security.JwtClaim;
import io.unitycatalog.server.security.SecurityContext;
import io.unitycatalog.server.utils.JwksOperations;
import io.unitycatalog.server.utils.ServerProperties;
import lombok.Builder;
import lombok.Getter;
import lombok.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import io.unitycatalog.server.exception.BaseException;
import io.unitycatalog.server.exception.ErrorCode;
import io.unitycatalog.server.utils.ServerProperties;
import io.unitycatalog.server.service.credential.CredentialContext;
import io.unitycatalog.server.utils.ServerProperties;
import java.time.Duration;
import java.util.Map;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import com.azure.storage.file.datalake.models.UserDelegationKey;
import com.azure.storage.file.datalake.sas.DataLakeServiceSasSignatureValues;
import com.azure.storage.file.datalake.sas.PathSasPermission;
import io.unitycatalog.server.utils.ServerProperties;
import io.unitycatalog.server.service.credential.CredentialContext;
import io.unitycatalog.server.utils.ServerProperties;
import java.net.URI;
import java.time.OffsetDateTime;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import com.google.common.base.CharMatcher;
import io.unitycatalog.server.exception.BaseException;
import io.unitycatalog.server.exception.ErrorCode;
import io.unitycatalog.server.utils.ServerProperties;
import io.unitycatalog.server.service.credential.CredentialContext;
import io.unitycatalog.server.utils.ServerProperties;
import java.io.IOException;
import java.net.URI;
import java.sql.Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ public Map<String, ADLSStorageConfig> getAdlsConfigurations() {

/**
* Get a property value by key.
* <p>
* The key can be one of the following (in that order)
* before looking it up in the server properties:
*
* <p>The key can be one of the following (in that order) before looking it up in the server
* properties:
*
* <ol>
* <li>System property</li>
* <li>Environment variable</li>
* <li>System property
* <li>Environment variable
* </ol>
* </p>
*/
public String getProperty(String key) {
if (System.getProperty(key) != null) return System.getProperty(key);
Expand All @@ -138,6 +138,7 @@ public String getProperty(String key) {

/**
* Get a property value by key with a default value
*
* @see Properties#getProperty(String key, String defaultValue)
*/
public String getProperty(String key, String defaultValue) {
Expand Down
Loading

0 comments on commit b8d08db

Please sign in to comment.