Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Improve metadata model #54

Merged
merged 14 commits into from
Oct 28, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.apache.paimon.web.api.exception.ColumnException;
import org.apache.paimon.web.api.exception.DatabaseException;
import org.apache.paimon.web.api.exception.TableException;
import org.apache.paimon.web.api.table.ColumnMetadata;
import org.apache.paimon.web.api.table.TableChange;
import org.apache.paimon.web.api.table.TableMetadata;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;
import org.apache.paimon.web.api.table.metadata.TableMetadata;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.paimon.web.api.table;

import org.apache.paimon.types.DataType;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
import org.apache.paimon.web.api.common.MetastoreType;
import org.apache.paimon.web.api.common.OperatorKind;
import org.apache.paimon.web.api.common.WriteMode;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;
import org.apache.paimon.web.api.table.metadata.ConsumerTableMetadata;
import org.apache.paimon.web.api.table.metadata.FileTableMetadata;
import org.apache.paimon.web.api.table.metadata.ManifestTableMetadata;
import org.apache.paimon.web.api.table.metadata.OptionTableMetadata;
import org.apache.paimon.web.api.table.metadata.SchemaTableMetadata;
import org.apache.paimon.web.api.table.metadata.SnapshotTableMetadata;
import org.apache.paimon.web.api.table.metadata.TableMetadata;
import org.apache.paimon.web.api.table.metadata.TagTableMetadata;
import org.apache.paimon.web.common.annotation.VisibleForTesting;
import org.apache.paimon.web.common.utils.ParameterValidationUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

import org.apache.paimon.types.DataType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

/** file table metadata. */
public class ConsumerTableMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

/** manifest table metadata. */
public class ManifestTableMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

/** options table metadata. */
public class OptionTableMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

import com.google.common.base.Preconditions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.paimon.web.api.table;
package org.apache.paimon.web.api.table.metadata;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.apache.paimon.types.DataTypes;
import org.apache.paimon.web.api.exception.DatabaseException;
import org.apache.paimon.web.api.exception.TableException;
import org.apache.paimon.web.api.table.ColumnMetadata;
import org.apache.paimon.web.api.table.TableChange;
import org.apache.paimon.web.api.table.TableMetadata;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;
import org.apache.paimon.web.api.table.metadata.TableMetadata;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.paimon.types.DataTypes;
import org.apache.paimon.web.api.catalog.CatalogCreator;
import org.apache.paimon.web.api.database.DatabaseManager;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;
import org.apache.paimon.web.api.table.metadata.TableMetadata;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down
5 changes: 5 additions & 0 deletions paimon-web-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ under the License.
<version>${hadoop.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.web.server.constant;

/** Metadata constant. */
public class MetadataConstant {
public static final String SNAPSHOTS = "snapshots";
public static final String SCHEMAS = "schemas";
public static final String OPTIONS = "options";
public static final String MANIFESTS = "manifests";
public static final String FILES = "files";
public static final String CONSUMER = "consumers";
public static final String TAGS = "tags";
public static final String METADATA_TABLE_FORMAT = "%s$%s";
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public R<Void> createDatabase(@RequestBody DatabaseDTO databaseDTO) {
}

/**
* /** Get all database information.
* Get all database information.
*
* @return The list of all databases.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import org.apache.paimon.web.server.data.dto.LoginDTO;
import org.apache.paimon.web.server.data.result.R;
import org.apache.paimon.web.server.data.vo.UserInfoVo;
import org.apache.paimon.web.server.data.vo.UserInfoVO;
import org.apache.paimon.web.server.service.UserService;

import cn.dev33.satoken.stp.SaTokenInfo;
Expand Down Expand Up @@ -48,7 +48,7 @@ public class LoginController {
* @return token string
*/
@PostMapping("/login")
public R<UserInfoVo> login(@RequestBody LoginDTO loginDTO) {
public R<UserInfoVO> login(@RequestBody LoginDTO loginDTO) {
return R.succeed(userService.login(loginDTO));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.web.server.controller;

import org.apache.paimon.web.server.data.dto.QueryMetadataDTO;
import org.apache.paimon.web.server.data.result.R;
import org.apache.paimon.web.server.data.vo.DataFileVO;
import org.apache.paimon.web.server.data.vo.ManifestsVO;
import org.apache.paimon.web.server.data.vo.SchemaVO;
import org.apache.paimon.web.server.data.vo.SnapshotVO;
import org.apache.paimon.web.server.service.MetadataService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** Metadata api controller. */
@Slf4j
@RestController
@RequestMapping("/api/metadata/query")
public class MetadataController {

private final MetadataService metadataService;

public MetadataController(MetadataService metadataService) {
this.metadataService = metadataService;
}

@PostMapping("/schema")
public R<List<SchemaVO>> getSchemaInfo(@RequestBody QueryMetadataDTO dto) {
return R.succeed(metadataService.getSchema(dto));
}

@PostMapping("/snapshot")
public R<List<SnapshotVO>> getSnapshotInfo(@RequestBody QueryMetadataDTO dto) {
return R.succeed(metadataService.getSnapshot(dto));
}

@PostMapping("/manifest")
public R<List<ManifestsVO>> getManifestInfo(@RequestBody QueryMetadataDTO dto) {
return R.succeed(metadataService.getManifest(dto));
}

@PostMapping("/dataFile")
public R<List<DataFileVO>> getDataFileInfo(@RequestBody QueryMetadataDTO dto) {
return R.succeed(metadataService.getDataFile(dto));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.paimon.web.server.data.result.R;
import org.apache.paimon.web.server.data.result.enums.Status;
import org.apache.paimon.web.server.data.tree.TreeSelect;
import org.apache.paimon.web.server.data.vo.RoleMenuTreeselectVo;
import org.apache.paimon.web.server.data.vo.RouterVo;
import org.apache.paimon.web.server.data.vo.RoleMenuTreeselectVO;
import org.apache.paimon.web.server.data.vo.RouterVO;
import org.apache.paimon.web.server.service.SysMenuService;
import org.apache.paimon.web.server.util.StringUtils;

Expand Down Expand Up @@ -73,12 +73,12 @@ public R<List<TreeSelect>> treeselect(SysMenu menu) {

/** Load the corresponding character menu list tree. */
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public R<RoleMenuTreeselectVo> roleMenuTreeselect(@PathVariable("roleId") Integer roleId) {
public R<RoleMenuTreeselectVO> roleMenuTreeselect(@PathVariable("roleId") Integer roleId) {
List<SysMenu> menus = menuService.selectMenuList();

List<TreeSelect> treeMenus = menuService.buildMenuTreeSelect(menus);
List<Integer> checkedKeys = menuService.selectMenuListByRoleId(roleId);
return R.succeed(new RoleMenuTreeselectVo(checkedKeys, treeMenus));
return R.succeed(new RoleMenuTreeselectVO(checkedKeys, treeMenus));
}

/** add new menu. */
Expand Down Expand Up @@ -119,7 +119,7 @@ public R<Void> remove(@PathVariable("menuId") Integer menuId) {

/** Get router list. */
@GetMapping("/getRouters")
public R<List<RouterVo>> getRouters() {
public R<List<RouterVO>> getRouters() {
int userId = StpUtil.getLoginIdAsInt();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return R.succeed(menuService.buildMenus(menus));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import org.apache.paimon.table.Table;
import org.apache.paimon.types.DataField;
import org.apache.paimon.web.api.catalog.PaimonService;
import org.apache.paimon.web.api.table.ColumnMetadata;
import org.apache.paimon.web.api.table.TableChange;
import org.apache.paimon.web.api.table.TableMetadata;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;
import org.apache.paimon.web.api.table.metadata.TableMetadata;
import org.apache.paimon.web.server.data.dto.TableDTO;
import org.apache.paimon.web.server.data.model.AlterTableRequest;
import org.apache.paimon.web.server.data.model.CatalogInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.web.server.data.dto;

import lombok.Data;

/** DTO of query metadata is used for getting table metadata. */
@Data
public class QueryMetadataDTO {

private String catalogName;
hunter-cloud09 marked this conversation as resolved.
Show resolved Hide resolved

private String databaseName;

private String tableName;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.web.server.data.model;

import lombok.Data;

/** Model of metadata fields. */
@Data
public class MetadataFieldsModel {

private int id;
hunter-cloud09 marked this conversation as resolved.
Show resolved Hide resolved

private String name;

private String type;

private String comment;
}
Loading
Loading