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
12 changes: 12 additions & 0 deletions lance-flink-1.18/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
<artifactId>lance-core</artifactId>
</dependency>

<!-- Lance Namespace:可插拔 Catalog 后端契约,及 OpenAPI 生成的
模型类(DescribeTableResponse / CreateTableRequest 等) -->
<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-core</artifactId>
</dependency>

<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-apache-client</artifactId>
</dependency>

<!-- Arrow -->
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
12 changes: 12 additions & 0 deletions lance-flink-1.19/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
<artifactId>lance-core</artifactId>
</dependency>

<!-- Lance Namespace:可插拔 Catalog 后端契约,及 OpenAPI 生成的
模型类(DescribeTableResponse / CreateTableRequest 等) -->
<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-core</artifactId>
</dependency>

<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-apache-client</artifactId>
</dependency>

<!-- Arrow -->
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
12 changes: 12 additions & 0 deletions lance-flink-1.20/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
<artifactId>lance-core</artifactId>
</dependency>

<!-- Lance Namespace:可插拔 Catalog 后端契约,及 OpenAPI 生成的
模型类(DescribeTableResponse / CreateTableRequest 等) -->
<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-core</artifactId>
</dependency>

<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-apache-client</artifactId>
</dependency>

<!-- Arrow -->
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
29 changes: 29 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,38 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Explicitly manage arrow-memory-core to align with arrow-memory-netty version -->
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory-core</artifactId>
<version>${arrow.version}</version>
</dependency>

<!-- ==================== Lance Namespace(可插拔 Catalog 后端契约)==================== -->
<!-- LanceNamespace 接口与插件注册表,所有 catalog 操作通过此接口路由到具体实现
(dir / rest / glue / hive2 / unity 等)。详见:
https://github.com/lancedb/lance-namespace -->
<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-core</artifactId>
<version>${lance-namespace.version}</version>
</dependency>

<!-- OpenAPI 生成的 Apache HTTP 客户端,提供 Request/Response 模型类
(DescribeTableResponse / CreateTableRequest 等),以及 RestNamespace 实现 -->
<dependency>
<groupId>org.lance</groupId>
<artifactId>lance-namespace-apache-client</artifactId>
<version>${lance-namespace.version}</version>
</dependency>

<!-- ==================== Apache Arrow ==================== -->
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.flink.connector.lance.catalog.namespace;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

/**
* Configuration for Lance Namespace integration.
*
* <p>Supports:
* <ul>
* <li>Namespace implementation selection ({@code dir}, {@code rest}, custom)</li>
* <li>Implementation-specific parameters (root path, REST URI)</li>
* <li>Extra level configuration (for Spark compatibility)</li>
* <li>Parent prefix support (for Hive 3 compatibility)</li>
* </ul>
*/
public class LanceNamespaceConfig {

// Configuration keys
public static final String KEY_IMPL = "impl";
public static final String KEY_ROOT = "root";
public static final String KEY_URI = "uri";
public static final String KEY_EXTRA_LEVEL = "extra_level";
public static final String KEY_PARENT = "parent";
public static final String KEY_PARENT_DELIMITER = "parent_delimiter";

private final String impl;
private final Map<String, String> properties;
private final Optional<String> extraLevel;
private final Optional<String> parent;
private final String parentDelimiter;

/**
* Create configuration from properties map.
*/
public static LanceNamespaceConfig from(Map<String, String> properties) {
return new LanceNamespaceConfig(properties);
}

/**
* Create builder for configuration.
*/
public static Builder builder() {
return new Builder();
}

private LanceNamespaceConfig(Map<String, String> properties) {
this.properties = new HashMap<>(Objects.requireNonNull(properties, "Properties cannot be null"));

// Extract required impl
this.impl = properties.get(KEY_IMPL);
if (this.impl == null || this.impl.isEmpty()) {
throw new IllegalArgumentException("Missing required configuration: " + KEY_IMPL);
}

// Extract optional extra level
String extraLevelValue = properties.get(KEY_EXTRA_LEVEL);
this.extraLevel = extraLevelValue != null && !extraLevelValue.isEmpty()
? Optional.of(extraLevelValue) : Optional.empty();

// Extract optional parent prefix
String parentValue = properties.get(KEY_PARENT);
this.parent = parentValue != null && !parentValue.isEmpty()
? Optional.of(parentValue) : Optional.empty();

// Extract parent delimiter
this.parentDelimiter = properties.getOrDefault(KEY_PARENT_DELIMITER, ".");
}

/**
* Get namespace implementation type.
*/
public String getImpl() {
return impl;
}

/**
* Get all configuration properties.
*/
public Map<String, String> getProperties() {
return Collections.unmodifiableMap(properties);
}

/**
* Get root path for directory namespace implementation.
*/
public Optional<String> getRoot() {
return Optional.ofNullable(properties.get(KEY_ROOT));
}

/**
* Get URI for REST namespace implementation.
*/
public Optional<String> getUri() {
return Optional.ofNullable(properties.get(KEY_URI));
}

/**
* Get extra level configuration (for Spark compatibility).
*/
public Optional<String> getExtraLevel() {
return extraLevel;
}

/**
* Get parent prefix configuration (for Hive 3 compatibility).
*/
public Optional<String> getParent() {
return parent;
}

/**
* Get parent delimiter.
*/
public String getParentDelimiter() {
return parentDelimiter;
}

/**
* Check if directory namespace implementation.
*/
public boolean isDirectoryNamespace() {
return "dir".equals(impl);
}

/**
* Check if REST namespace implementation.
*/
public boolean isRestNamespace() {
return "rest".equals(impl);
}

@Override
public String toString() {
return "LanceNamespaceConfig{"
+ "impl='" + impl + '\''
+ ", extraLevel=" + extraLevel
+ ", parent=" + parent
+ '}';
}

/**
* Builder for LanceNamespaceConfig.
*/
public static class Builder {
private final Map<String, String> properties = new HashMap<>();

public Builder impl(String impl) {
properties.put(KEY_IMPL, impl);
return this;
}

public Builder root(String root) {
properties.put(KEY_ROOT, root);
return this;
}

public Builder uri(String uri) {
properties.put(KEY_URI, uri);
return this;
}

public Builder extraLevel(String extraLevel) {
properties.put(KEY_EXTRA_LEVEL, extraLevel);
return this;
}

public Builder parent(String parent) {
properties.put(KEY_PARENT, parent);
return this;
}

public Builder parentDelimiter(String delimiter) {
properties.put(KEY_PARENT_DELIMITER, delimiter);
return this;
}

public Builder property(String key, String value) {
properties.put(key, value);
return this;
}

public Builder properties(Map<String, String> props) {
properties.putAll(props);
return this;
}

public LanceNamespaceConfig build() {
return new LanceNamespaceConfig(properties);
}
}
}
Loading