Skip to content
Open
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
79 changes: 78 additions & 1 deletion docs/static/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2911,9 +2911,86 @@ components:
type: object
properties:
filter:
$ref: '#/components/schemas/Filter'
Filter:
oneOf:
- $ref: '#/components/schemas/CompoundFilter'
- $ref: '#/components/schemas/TransformFilter'
discriminator:
propertyName: type
CompoundFilter:
type: object
required:
- type
- function
- children
properties:
type:
type: string
enum: [compound]
function:
type: string
enum: [AND, OR]
children:
type: array
items:
type: string
$ref: '#/components/schemas/Filter'
TransformFilter:
type: object
required:
- type
- transform
- function
- literals
properties:
type:
type: string
enum: [transform]
transform:
$ref: '#/components/schemas/FilterTransform'
function:
type: string
enum:
- EQUAL
- NOT_EQUAL
- GREATER_THAN
- GREATER_OR_EQUAL
- LESS_THAN
- LESS_OR_EQUAL
- IN
- NOT_IN
- IS_NULL
- IS_NOT_NULL
- STARTS_WITH
- ENDS_WITH
- CONTAINS
- LIKE
literals:
type: array
items:
nullable: true
FilterTransform:
oneOf:
- $ref: '#/components/schemas/FieldFilterTransform'
discriminator:
propertyName: type
FieldFilterTransform:
type: object
required:
- type
- index
- name
- dataType
properties:
type:
type: string
enum: [field]
index:
type: integer
name:
type: string
dataType:
type: string
AlterDatabaseRequest:
type: object
properties:
Expand Down
3 changes: 2 additions & 1 deletion paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.paimon.rest.exceptions.AlreadyExistsException;
import org.apache.paimon.rest.exceptions.ForbiddenException;
import org.apache.paimon.rest.exceptions.NoSuchResourceException;
import org.apache.paimon.rest.filter.Filter;
import org.apache.paimon.rest.requests.AlterDatabaseRequest;
import org.apache.paimon.rest.requests.AlterFunctionRequest;
import org.apache.paimon.rest.requests.AlterTableRequest;
Expand Down Expand Up @@ -660,7 +661,7 @@ public void alterTable(Identifier identifier, List<SchemaChange> changes) {
* @throws ForbiddenException Exception thrown on HTTP 403 means don't have the permission for
* this table
*/
public List<String> authTableQuery(Identifier identifier, @Nullable List<String> select) {
public @Nullable Filter authTableQuery(Identifier identifier, @Nullable List<String> select) {
AuthTableQueryRequest request = new AuthTableQueryRequest(select);
AuthTableQueryResponse response =
client.post(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.paimon.rest.filter;

import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonGetter;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
* A compound filter which combines child {@link Filter}s using a {@link CompoundFilterFunction}.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class CompoundFilter implements Filter {

private static final String FIELD_FUNCTION = "function";
private static final String FIELD_CHILDREN = "children";

private final CompoundFilterFunction function;
private final List<Filter> children;

@JsonCreator
public CompoundFilter(
@JsonProperty(FIELD_FUNCTION) CompoundFilterFunction function,
@JsonProperty(FIELD_CHILDREN) List<Filter> children) {
this.function = function;
this.children = children;
}

@JsonGetter(FIELD_FUNCTION)
public CompoundFilterFunction function() {
return function;
}

@JsonGetter(FIELD_CHILDREN)
public List<Filter> children() {
return children;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.paimon.rest.filter;

/** Boolean operator used to combine multiple {@link Filter} expressions. */
public enum CompoundFilterFunction {
AND,
OR
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.paimon.rest.filter;

import org.apache.paimon.types.DataType;

import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonGetter;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonProperty;

/**
* A {@link FilterTransform} which references a table field (index/name/type) as the transform
* input.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class FieldFilterTransform implements FilterTransform {

private static final String FIELD_INDEX = "index";
private static final String FIELD_NAME = "name";
private static final String FIELD_DATA_TYPE = "dataType";

private final int index;
private final String name;
private final DataType dataType;

@JsonCreator
public FieldFilterTransform(
@JsonProperty(FIELD_INDEX) int index,
@JsonProperty(FIELD_NAME) String name,
@JsonProperty(FIELD_DATA_TYPE) DataType dataType) {
this.index = index;
this.name = name;
this.dataType = dataType;
}

@JsonGetter(FIELD_INDEX)
public int index() {
return index;
}

@JsonGetter(FIELD_NAME)
public String name() {
return name;
}

@JsonGetter(FIELD_DATA_TYPE)
public DataType dataType() {
return dataType;
}
}
30 changes: 30 additions & 0 deletions paimon-api/src/main/java/org/apache/paimon/rest/filter/Filter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.paimon.rest.filter;

import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonSubTypes;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo;

/** Base interface for REST filter expressions. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = CompoundFilter.class, name = "compound"),
@JsonSubTypes.Type(value = TransformFilter.class, name = "transform")
})
public interface Filter {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.paimon.rest.filter;

import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonSubTypes;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo;

/** Transform applied to a field before evaluating a {@link Filter} in REST requests. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({@JsonSubTypes.Type(value = FieldFilterTransform.class, name = "field")})
public interface FilterTransform {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.paimon.rest.filter;

/** Supported leaf comparison functions for REST {@link Filter} expressions. */
public enum LeafFilterFunction {
EQUAL,
NOT_EQUAL,
GREATER_THAN,
GREATER_OR_EQUAL,
LESS_THAN,
LESS_OR_EQUAL,
IN,
NOT_IN,
IS_NULL,
IS_NOT_NULL,
STARTS_WITH,
ENDS_WITH,
CONTAINS,
LIKE
}
Loading
Loading