Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ nav:
- CreateTable: spec/impls/rest/create-table.md
- Directory: spec/impls/dir.md
- Apache Hive MetaStore: spec/impls/hive.md
- Apache Iceberg REST Catalog: spec/impls/iceberg.md
- Tool Integration: spec/tools.md
- OpenAPI: https://editor-next.swagger.io/?url=https://raw.githubusercontent.com/lancedb/lance-namespace/refs/heads/main/docs/src/spec/rest.yaml
- User Guide:
Expand Down
23 changes: 23 additions & 0 deletions docs/src/spec/impls/glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
**Lance Glue Namespace** is an implementation using AWS Glue Data Catalog.
For more details about AWS Glue, please read the [AWS Glue Data Catalog Documentation](https://docs.aws.amazon.com/glue/).

## Configuration

The Lance Glue namespace accepts the following configuration properties:

| Property | Required | Description | Default | Example |
|---------------------|----------|-----------------------------------------------------------------|---------------------------|---------------------------------|
| `catalog_id` | No | The Catalog ID of the Glue catalog (defaults to AWS account ID) | | `123456789012` |
| `endpoint` | No | Custom Glue service endpoint for API compatible metastores | | `https://glue.example.com` |
| `region` | No | AWS region for all Glue operations | | `us-west-2` |
| `access_key_id` | No | AWS access key ID for static credentials | | |
| `secret_access_key` | No | AWS secret access key for static credentials | | |
| `session_token` | No | AWS session token for temporary credentials | | |
| `root` | No | Storage root location of the lakehouse on Glue catalog | Current working directory | `/my/dir`, `s3://bucket/prefix` |
| `storage.*` | No | Additional storage configurations to access table | | `storage.region=us-west-2` |

### Authentication

The Glue namespace supports multiple authentication methods:

1. **Default AWS credential provider chain**: When no explicit credentials are provided, the client uses the default AWS credential provider chain
2. **Static credentials**: Set `access_key_id` and `secret_access_key` for basic AWS credentials
3. **Session credentials**: Additionally provide `session_token` for temporary AWS credentials

## Namespace Mapping

An AWS Glue Data Catalog can be viewed as the root Lance namespace.
Expand Down
18 changes: 17 additions & 1 deletion docs/src/spec/impls/hive.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

**Lance Hive Namespace** is an implementation using Apache Hive MetaStore (HMS).
For more details about HMS, please read [HMS AdminManual 2.x](https://hive.apache.org/docs/latest/adminmanual-metastore-administration_27362076/)
and [HMS AdminManual 3.x](https://hive.apache.org/docs/latest/adminmanual-metastore-3-0-administration_75978150/).
and [HMS AdminManual 3.x](https://hive.apache.org/docs/latest/adminmanual-metastore-3-0-administration_75978150/).

## Configuration

The Lance Hive namespace accepts the following configuration properties:

| Property | Required | Description | Default | Example |
|--------------------|----------|--------------------------------------------------------|---------------------------|---------------------------------|
| `client.pool-size` | No | Size of the HMS client connection pool | 3 | `5` |
| `root` | No | Storage root location of the lakehouse on Hive catalog | Current working directory | `/my/dir`, `s3://bucket/prefix` |
| `storage.*` | No | Additional storage configurations to access table | | `storage.region=us-west-2` |

### Version-specific Configuration

**Hive 2.x**: Uses the configuration properties listed above.

**Hive 3.x**: Uses the same configuration properties as Hive 2.x, with an additional catalog name constant (`hive`) for catalog-level operations.

## Namespace Mapping

Expand Down
51 changes: 0 additions & 51 deletions docs/src/spec/impls/iceberg.md

This file was deleted.

2 changes: 1 addition & 1 deletion java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = 0.0.5
VERSION = 0.0.6

.PHONY: clean-apache-client
clean-apache-client:
Expand Down
2 changes: 1 addition & 1 deletion java/lance-namespace-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.lancedb</groupId>
<artifactId>lance-namespace-root</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
6 changes: 3 additions & 3 deletions java/lance-namespace-apache-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.lancedb</groupId>
<artifactId>lance-namespace-apache-client</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -61,7 +61,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:

```groovy
compile "com.lancedb:lance-namespace-apache-client:0.0.5"
compile "com.lancedb:lance-namespace-apache-client:0.0.6"
```

### Others
Expand All @@ -74,7 +74,7 @@ mvn clean package

Then manually install the following JARs:

- `target/lance-namespace-apache-client-0.0.5.jar`
- `target/lance-namespace-apache-client-0.0.6.jar`
- `target/lib/*.jar`

## Getting Started
Expand Down
4 changes: 2 additions & 2 deletions java/lance-namespace-apache-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>lance-namespace-apache-client</artifactId>
<packaging>jar</packaging>
<name>lance-namespace-apache-client</name>
<version>0.0.5</version>
<version>0.0.6</version>
<url>https://github.com/openapitools/openapi-generator</url>
<description>OpenAPI Java</description>
<scm>
Expand All @@ -16,7 +16,7 @@
<parent>
<groupId>com.lancedb</groupId>
<artifactId>lance-namespace-root</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
</parent>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public ApiClient(CloseableHttpClient httpClient) {
dateFormat = ApiClient.buildDefaultDateFormat();

// Set default User-Agent.
setUserAgent("OpenAPI-Generator/0.0.5/java");
setUserAgent("OpenAPI-Generator/0.0.6/java");

// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
public class Configuration {
public static final String VERSION = "0.0.5";
public static final String VERSION = "0.0.6";

private static volatile ApiClient defaultApiClient = new ApiClient();

Expand Down
23 changes: 14 additions & 9 deletions java/lance-namespace-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.lancedb</groupId>
<artifactId>lance-namespace-root</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -37,7 +37,19 @@
<groupId>org.apache.opendal</groupId>
<artifactId>opendal</artifactId>
<version>0.48.0</version>
<classifier>${os.detected.classifier}</classifier>
<classifier>linux-aarch_64</classifier>
</dependency>
<dependency>
<groupId>org.apache.opendal</groupId>
<artifactId>opendal</artifactId>
<version>0.48.0</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.apache.opendal</groupId>
<artifactId>opendal</artifactId>
<version>0.48.0</version>
<classifier>osx-aarch_64</classifier>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down Expand Up @@ -103,13 +115,6 @@
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.0</version>
</extension>
</extensions>
</build>
<profiles>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public LanceNamespaceException(ApiException e) {
}

public LanceNamespaceException(ErrorResponse errorResponse) {
super(errorResponse.getError());
super(errorResponse.toString());
this.code = errorResponse.getCode() == null ? UNKNOWN_ERROR_CODE : errorResponse.getCode();
this.errorResponse = Optional.of(errorResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.lancedb.lance.namespace.model.ListTablesRequest;
import com.lancedb.lance.namespace.model.ListTablesResponse;
import com.lancedb.lance.namespace.model.NamespaceExistsRequest;
import com.lancedb.lance.namespace.model.TableExistsRequest;
import com.lancedb.lance.namespace.util.JsonArrowSchemaConverter;
import com.lancedb.lance.namespace.util.OpenDalUtil;
import com.lancedb.lance.namespace.util.ValidationUtil;
Expand Down Expand Up @@ -64,7 +65,8 @@ public class DirectoryNamespace implements LanceNamespace, Closeable {
public void initialize(Map<String, String> configProperties, BufferAllocator allocator) {
this.config = new DirectoryNamespaceConfig(configProperties);
this.allocator = allocator;
this.operator = OpenDalUtil.initializeOperator(this.config.getRoot());
this.operator =
OpenDalUtil.initializeOperator(this.config.getRoot(), this.config.getStorageOptions());
}

@Override
Expand Down Expand Up @@ -123,6 +125,7 @@ public CreateTableResponse createTable(CreateTableRequest request, byte[] reques
CreateTableResponse response = new CreateTableResponse();
response.setLocation(tablePath);
response.setVersion(1L);
response.setStorageOptions(config.getStorageOptions());
return response;
}

Expand Down Expand Up @@ -180,6 +183,24 @@ public ListTablesResponse listTables(ListTablesRequest request) {
return response;
}

@Override
public void tableExists(TableExistsRequest request) {
String tableName = tableNameFromId(request.getId());

LOG.debug("Checking if table {} exists", tableName);

String versionsPath = tableVersionsPath(tableName);
List<Entry> versionEntries =
operator.list(versionsPath, ListOptions.builder().limit(1).build());
if (versionEntries.isEmpty()) {
throw LanceNamespaceException.notFound(
"Table does not exist: " + tableName,
"TABLE_NOT_FOUND",
tableName,
"The requested table was not found in the namespace");
}
}

@Override
public DescribeTableResponse describeTable(DescribeTableRequest request) {
String tableName = tableNameFromId(request.getId());
Expand Down Expand Up @@ -208,6 +229,7 @@ public DescribeTableResponse describeTable(DescribeTableRequest request) {

DescribeTableResponse response = new DescribeTableResponse();
response.setLocation(tablePath);
response.setStorageOptions(config.getStorageOptions());
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.lancedb.lance.namespace.dir;

import com.lancedb.lance.namespace.util.OpenDalUtil;
import com.lancedb.lance.namespace.util.PropertyUtil;

import java.io.Serializable;
Expand All @@ -29,7 +30,9 @@ public class DirectoryNamespaceConfig implements Serializable {
private final Map<String, String> storageOptions;

public DirectoryNamespaceConfig(Map<String, String> properties) {
this.root = PropertyUtil.propertyAsString(properties, ROOT, ROOT_DEFAULT);
this.root =
OpenDalUtil.stripTrailingSlash(
PropertyUtil.propertyAsString(properties, ROOT, ROOT_DEFAULT));
this.storageOptions = PropertyUtil.propertiesWithPrefix(properties, STORAGE_OPTIONS_PREFIX);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
*/
package com.lancedb.lance.namespace.util;

import com.google.common.collect.ImmutableMap;
import org.apache.opendal.Operator;

import java.util.HashMap;
import java.util.Map;

/** Utility class for OpenDAL operations and configurations. */
public class OpenDalUtil {

Expand All @@ -24,33 +26,53 @@ private OpenDalUtil() {
}

/**
* Initialize an OpenDAL operator based on the root path.
* Initialize an OpenDAL operator based on the root path and storage options.
*
* @param root the root path/URI
* @param storageOptions additional storage configuration options (credentials, endpoints, etc.)
* @return configured OpenDAL operator
*/
public static Operator initializeOperator(String root) {
public static Operator initializeOperator(String root, Map<String, String> storageOptions) {
String[] schemeSplit = root.split("://", -1);

// local file system path
if (schemeSplit.length < 2) {
return Operator.of("fs", ImmutableMap.of("root", root));
Map<String, String> config = new HashMap<>();
config.put("root", root);
if (storageOptions != null) {
config.putAll(storageOptions);
}
return Operator.of("fs", config);
}

String scheme = normalizeScheme(schemeSplit[0]);
String[] authoritySplit = schemeSplit[1].split("/", 2);
String authority = authoritySplit[0];
String path = authoritySplit.length > 1 ? authoritySplit[1] : "";

Map<String, String> config = new HashMap<>();

switch (scheme) {
case "s3":
case "gcs":
return Operator.of(scheme, ImmutableMap.of("root", path, "bucket", authority));
config.put("root", path);
config.put("bucket", authority);
break;
case "azblob":
return Operator.of(scheme, ImmutableMap.of("root", path, "CONTAINER", authority));
config.put("root", path);
config.put("CONTAINER", authority);
break;
default:
return Operator.of(scheme, ImmutableMap.of("root", schemeSplit[1]));
config.put("root", schemeSplit[1]);
break;
}

// Add storage options
if (storageOptions != null) {
config.putAll(storageOptions);
}

return Operator.of(scheme, config);
}

/**
Expand Down
Loading
Loading