repo stringclasses 1k values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 6 values | commit_sha stringclasses 1k values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/DatabaseMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/DatabaseMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.vo.DatabaseVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** Database table mapper. */
@Mapper
public interface DatabaseMapper extends BaseMapper<DatabaseVO> {}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/TenantMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/TenantMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.Tenant;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** tenant table mapper. */
@Mapper
public interface TenantMapper extends BaseMapper<Tenant> {}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/SysMenuMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/SysMenuMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** Menu mapper. */
@Mapper
public interface SysMenuMapper extends BaseMapper<SysMenu> {
/**
* Query system menu list.
*
* @param menu query params
* @return result
*/
List<SysMenu> selectMenuList(@Param("menu") SysMenu menu);
/**
* Query all menu perms.
*
* @return permission List
*/
List<String> selectMenuPerms();
/**
* Query system menu list by user.
*
* @param menu query params
* @return menu list
*/
List<SysMenu> selectMenuListByUserId(
@Param("menu") SysMenu menu, @Param("userId") Integer userId);
/**
* Query permissions based on role ID.
*
* @param roleId role ID
* @return permission List
*/
List<String> selectMenuPermsByRoleId(Integer roleId);
/**
* Query permissions by user ID.
*
* @param userId user ID
* @return permission List
*/
List<String> selectMenuPermsByUserId(Integer userId);
/**
* Query all menu list.
*
* @return menu list
*/
List<SysMenu> selectMenuTreeAll();
/**
* Query menu list by user ID.
*
* @param userId user ID
* @return menu list
*/
List<SysMenu> selectMenuTreeByUserId(Integer userId);
/**
* Query menu tree information based on role ID.
*
* @param roleId role ID
* @return selected menu list
*/
List<Integer> selectMenuListByRoleId(Integer roleId);
/**
* Query information by menu ID.
*
* @param menuId menu ID
* @return menu info
*/
SysMenu selectMenuById(Integer menuId);
/**
* Is there a menu sub node present.
*
* @param menuId menu ID
* @return result
*/
int hasChildByMenuId(Integer menuId);
/**
* Verify if the menu name is unique.
*
* @param menuName menu name
* @param parentId parent ID
* @return result
*/
SysMenu checkMenuNameUnique(
@Param("menuName") String menuName, @Param("parentId") Integer parentId);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/HistoryMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/HistoryMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.History;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** History mapper. */
@Mapper
public interface HistoryMapper extends BaseMapper<History> {
List<History> listHistories(IPage<History> page, @Param("history") History history);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/SysRoleMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/SysRoleMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** Role Mapper. */
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
List<SysRole> selectRoleList(IPage<SysRole> page, @Param("role") SysRole role);
/**
* Query roles by user ID.
*
* @param userId user ID
* @return role list
*/
List<SysRole> selectRolePermissionByUserId(Integer userId);
/**
* Query all roles.
*
* @return role list
*/
List<SysRole> selectRoleAll();
/**
* Obtain a list of role selection boxes by user ID.
*
* @param userId user ID
* @return result
*/
List<Integer> selectRoleListByUserId(Integer userId);
/**
* Query role info by role ID.
*
* @param roleId role ID
* @return role info
*/
SysRole selectRoleById(Integer roleId);
/**
* Query role info by user.
*
* @param userName user name
* @return role list
*/
List<SysRole> selectRolesByUserName(String userName);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/StatementMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/StatementMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.StatementInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** Statement mapper. */
@Mapper
public interface StatementMapper extends BaseMapper<StatementInfo> {
List<StatementInfo> listStatements(
IPage<StatementInfo> page, @Param("statement") StatementInfo statement);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/RoleMenuMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/RoleMenuMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.RoleMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** role-menu mapper. */
@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
/**
* Query menu usage quantity.
*
* @param menuId menu ID
* @return result
*/
int checkMenuExistRole(Integer menuId);
/**
* Delete roles and menu associations through role ID.
*
* @param roleId role ID
* @return result
*/
int deleteRoleMenuByRoleId(Integer roleId);
/**
* Batch delete role menu association information.
*
* @param roleIds roleIds
* @return result
*/
int deleteRoleMenu(Integer[] roleIds);
/**
* Batch Add Role Menu Information.
*
* @param roleMenuList role-menu List
* @return result
*/
int batchRoleMenu(List<RoleMenu> roleMenuList);
/**
* Query the menu permissions that users have.
*
* @param userId user ID
* @return result
*/
List<RoleMenu> queryRoleMenuByUser(Integer userId);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/ClusterMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/ClusterMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.ClusterInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** Cluster mapper. */
@Mapper
public interface ClusterMapper extends BaseMapper<ClusterInfo> {
List<ClusterInfo> listClusters(IPage<ClusterInfo> page, @Param("cluster") ClusterInfo cluster);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CdcJobDefinitionMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CdcJobDefinitionMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.CdcJobDefinition;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** CdcJobDefinition table mapper. */
public interface CdcJobDefinitionMapper extends BaseMapper<CdcJobDefinition> {}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/JobMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/JobMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.JobInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** Job mapper. */
@Mapper
public interface JobMapper extends BaseMapper<JobInfo> {}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/UserTenantMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/UserTenantMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.UserTenant;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** user_tenant table mapper. */
@Mapper
public interface UserTenantMapper extends BaseMapper<UserTenant> {}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CatalogMapper.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CatalogMapper.java | /*
* 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.mapper;
import org.apache.paimon.web.server.data.model.CatalogInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** Catalog table mapper. */
@Mapper
public interface CatalogMapper extends BaseMapper<CatalogInfo> {}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/TenantContextHolder.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/TenantContextHolder.java | /*
* 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.context;
/** TenantContextHolder. */
public class TenantContextHolder {
private static final ThreadLocal<Long> TENANT_CONTEXT = new InheritableThreadLocal<>();
public static void set(Long value) {
TENANT_CONTEXT.set(value);
}
public static Long get() {
return TENANT_CONTEXT.get();
}
public static void clear() {
TENANT_CONTEXT.remove();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/LogContextHolder.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/LogContextHolder.java | /*
* 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.context;
import org.apache.paimon.web.server.context.logtool.LogEntity;
import org.apache.paimon.web.server.context.logtool.LogWritePool;
/** Use Thread local cache log. */
public class LogContextHolder {
private static final ThreadLocal<LogEntity> PROCESS_CONTEXT = new ThreadLocal<>();
public static void setProcess(LogEntity process) {
PROCESS_CONTEXT.set(process);
}
public static LogEntity getProcess() {
if (PROCESS_CONTEXT.get() == null) {
return LogEntity.NULL_PROCESS;
}
return PROCESS_CONTEXT.get();
}
public static LogEntity registerProcess(LogEntity process) {
setProcess(process);
LogWritePool.getInstance().push(process.getName(), process);
return process;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogWritePool.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogWritePool.java | /*
* 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.context.logtool;
import org.apache.paimon.web.server.util.LRUCache;
/** log write pool is used for write logs to process thread local. */
public class LogWritePool extends AbstractPool<LogEntity> {
private static final LRUCache<String, LogEntity> logEntityCache = new LRUCache<>(64);
private static final LogWritePool instance = new LogWritePool();
public static LogWritePool getInstance() {
return instance;
}
@Override
public LRUCache<String, LogEntity> getLRUCache() {
return logEntityCache;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogStatus.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogStatus.java | /*
* 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.context.logtool;
/** log status. */
public enum LogStatus {
INITIALIZING("INITIALIZING"),
RUNNING("RUNNING"),
FAILED("FAILED"),
CANCELED("CANCELED"),
FINISHED("FINISHED"),
UNKNOWN("UNKNOWN");
private String value;
LogStatus(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static LogStatus get(String value) {
for (LogStatus type : LogStatus.values()) {
if (type.getValue().equalsIgnoreCase(value)) {
return type;
}
}
return LogStatus.UNKNOWN;
}
public boolean equalsValue(String type) {
if (value.equalsIgnoreCase(type)) {
return true;
}
return false;
}
public boolean isActiveStatus() {
switch (this) {
case INITIALIZING:
case RUNNING:
return true;
default:
return false;
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogEntity.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogEntity.java | /*
* 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.context.logtool;
import org.apache.paimon.web.server.util.LocalDateTimeUtil;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/** log entity. */
public class LogEntity {
private String pid;
private String name;
private Integer taskId;
private LogType type;
private LogStatus status;
private LocalDateTime startTime;
private LocalDateTime endTime;
private long time;
private int stepIndex = 0;
private List<LogStep> steps;
private String userId;
public static final LogEntity NULL_PROCESS = new LogEntity();
public LogEntity() {}
public LogEntity(String pid, String name, Integer taskId, LogType type, String userId) {
this.pid = pid;
this.name = name;
this.taskId = taskId;
this.type = type;
this.userId = userId;
}
public LogEntity(
String name,
Integer taskId,
LogType type,
LogStatus status,
LocalDateTime startTime,
LocalDateTime endTime,
long time,
List<LogStep> steps,
String userId) {
this.name = name;
this.taskId = taskId;
this.type = type;
this.status = status;
this.startTime = startTime;
this.endTime = endTime;
this.time = time;
this.steps = steps;
this.userId = userId;
}
public static LogEntity init(LogType type, String submitId) {
return init(type.getValue() + "_TEMP", null, type, submitId);
}
public static LogEntity init(Integer taskId, LogType type, String submitId) {
return init(type.getValue() + taskId, taskId, type, submitId);
}
public static LogEntity init(String name, Integer taskId, LogType type, String submitId) {
LogEntity process =
new LogEntity(UUID.randomUUID().toString(), name, taskId, type, submitId);
process.setStatus(LogStatus.INITIALIZING);
process.setStartTime(LocalDateTime.now());
process.setSteps(new ArrayList<>());
process.getSteps().add(LogStep.init());
process.nextStep();
return process;
}
public void start() {
if (isNullProcess()) {
return;
}
steps.get(stepIndex - 1).setEndTime(LocalDateTime.now());
setStatus(LogStatus.RUNNING);
steps.add(LogStep.run());
nextStep();
}
public void finish() {
if (isNullProcess()) {
return;
}
steps.get(stepIndex - 1).setEndTime(LocalDateTime.now());
setStatus(LogStatus.FINISHED);
setEndTime(LocalDateTime.now());
setTime(getEndTime().compareTo(getStartTime()));
}
public void finish(String str) {
if (isNullProcess()) {
return;
}
steps.get(stepIndex - 1).setEndTime(LocalDateTime.now());
String message =
String.format(
"\n[%s] INFO: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
setStatus(LogStatus.FINISHED);
setEndTime(LocalDateTime.now());
setTime(getEndTime().compareTo(getStartTime()));
LogReadPool.write(message, userId);
}
public void config(String str) {
if (isNullProcess()) {
return;
}
String message =
String.format(
"\n[%s] CONFIG: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
LogReadPool.write(message, userId);
}
public void info(String str) {
if (isNullProcess()) {
return;
}
String message =
String.format(
"\n[%s] INFO: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
LogReadPool.write(message, userId);
}
public void infoSuccess() {
if (isNullProcess()) {
return;
}
steps.get(stepIndex - 1).appendInfo("Success.");
LogReadPool.write("Success.", userId);
}
public void infoFail() {
if (isNullProcess()) {
return;
}
steps.get(stepIndex - 1).appendInfo("Fail.");
LogReadPool.write("Fail.", userId);
}
public void error(String str) {
if (isNullProcess()) {
return;
}
String message =
String.format(
"\n[%s] ERROR: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
steps.get(stepIndex - 1).appendError(message);
LogReadPool.write(message, userId);
}
public void nextStep() {
if (isNullProcess()) {
return;
}
stepIndex++;
}
public boolean isNullProcess() {
return pid == null;
}
public boolean isActiveProcess() {
return status.isActiveStatus();
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getTaskId() {
return taskId;
}
public void setTaskId(Integer taskId) {
this.taskId = taskId;
}
public LogType getType() {
return type;
}
public void setType(LogType type) {
this.type = type;
}
public LogStatus getStatus() {
return status;
}
public void setStatus(LogStatus status) {
this.status = status;
}
public LocalDateTime getStartTime() {
return startTime;
}
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
public LocalDateTime getEndTime() {
return endTime;
}
public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public List<LogStep> getSteps() {
return steps;
}
public void setSteps(List<LogStep> steps) {
this.steps = steps;
}
public int getStepIndex() {
return stepIndex;
}
public void setStepIndex(int stepIndex) {
this.stepIndex = stepIndex;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogException.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogException.java | /*
* 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.context.logtool;
import org.apache.paimon.web.server.context.LogContextHolder;
import org.apache.paimon.web.server.util.LogUtil;
/** log exception. */
public class LogException extends RuntimeException {
public LogException() {}
public LogException(String message) {
super(message);
LogContextHolder.getProcess().error(message);
}
public LogException(String message, Throwable cause) {
super(message, cause);
LogContextHolder.getProcess().error(LogUtil.getError(cause));
}
public LogException(Throwable cause) {
super(cause);
LogContextHolder.getProcess().error(cause.toString());
}
public LogException(
String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
LogContextHolder.getProcess().error(LogUtil.getError(cause));
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogType.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogType.java | /*
* 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.context.logtool;
/** support batch streaming. */
public enum LogType {
STREAMING("Streaming"),
BATCH("Batch"),
UNKNOWN("Unknown");
private String value;
LogType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static LogType get(String value) {
for (LogType type : LogType.values()) {
if (type.getValue().equalsIgnoreCase(value)) {
return type;
}
}
return LogType.UNKNOWN;
}
public boolean equalsValue(String type) {
return value.equalsIgnoreCase(type);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/AbstractPool.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/AbstractPool.java | /*
* 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.context.logtool;
import org.apache.paimon.web.server.util.LRUCache;
/** log abstract. */
public abstract class AbstractPool<T> {
public abstract LRUCache<String, T> getLRUCache();
public boolean exist(String key) {
return getLRUCache().containsKey(key);
}
public int push(String key, T entity) {
getLRUCache().put(key, entity);
return getLRUCache().size();
}
public int remove(String key) {
getLRUCache().remove(key);
return getLRUCache().size();
}
public T get(String key) {
return getLRUCache().get(key);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogStep.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogStep.java | /*
* 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.context.logtool;
import java.time.LocalDateTime;
/** Record the current log write to step. */
public class LogStep {
private LogStatus stepStatus;
private LocalDateTime startTime;
private LocalDateTime endTime;
private long time;
private StringBuilder info = new StringBuilder();
private StringBuilder error = new StringBuilder();
private boolean isError = false;
public LogStep() {}
public LogStep(LogStatus stepStatus, LocalDateTime startTime) {
this(stepStatus, startTime, null, 0, new StringBuilder(), new StringBuilder());
}
public LogStep(
LogStatus stepStatus,
LocalDateTime startTime,
LocalDateTime endTime,
long time,
StringBuilder info,
StringBuilder error) {
this.stepStatus = stepStatus;
this.startTime = startTime;
this.endTime = endTime;
this.time = time;
this.info = info;
this.error = error;
}
public static LogStep init() {
return new LogStep(LogStatus.INITIALIZING, LocalDateTime.now());
}
public static LogStep run() {
return new LogStep(LogStatus.RUNNING, LocalDateTime.now());
}
public void appendInfo(String str) {
info.append(str);
}
public void appendError(String str) {
error.append(str);
isError = true;
}
public LogStatus getStepStatus() {
return stepStatus;
}
public void setStepStatus(LogStatus stepStatus) {
this.stepStatus = stepStatus;
}
public LocalDateTime getStartTime() {
return startTime;
}
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
public LocalDateTime getEndTime() {
return endTime;
}
public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
this.time = endTime.compareTo(startTime);
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public StringBuilder getInfo() {
return info;
}
public void setInfo(StringBuilder info) {
this.info = info;
}
public StringBuilder getError() {
return error;
}
public void setError(StringBuilder error) {
this.error = error;
}
public boolean isError() {
return isError;
}
public void setError(boolean error) {
isError = error;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java | paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java | /*
* 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.context.logtool;
import org.apache.paimon.web.server.util.LRUCache;
/** log read pool for console read. */
public class LogReadPool extends AbstractPool<StringBuilder> {
private static final LRUCache<String, StringBuilder> consoleEntityCache = new LRUCache<>(64);
private static final LogReadPool instance = new LogReadPool();
public static LogReadPool getInstance() {
return instance;
}
@Override
public LRUCache<String, StringBuilder> getLRUCache() {
return consoleEntityCache;
}
public static void write(String str, String userId) {
consoleEntityCache.computeIfAbsent(userId, k -> new StringBuilder()).append(str);
}
public static void clear(String userId) {
consoleEntityCache.put(userId, new StringBuilder());
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/TestBase.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/TestBase.java | /*
* 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.engine.flink.sql.gataway;
import org.apache.commons.io.FileUtils;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.testutils.CommonTestUtils;
import org.apache.flink.table.gateway.api.SqlGatewayService;
import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
import org.apache.flink.table.gateway.rest.SqlGatewayRestEndpoint;
import org.apache.flink.table.gateway.rest.util.SqlGatewayRestOptions;
import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
import org.apache.flink.table.gateway.service.context.DefaultContext;
import org.apache.flink.table.gateway.service.session.SessionManager;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.Extension;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.rules.TemporaryFolder;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import static org.apache.flink.configuration.ConfigConstants.ENV_FLINK_CONF_DIR;
import static org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils.getEndpointConfig;
import static org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils.getSqlGatewayOptionPrefix;
import static org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory.IDENTIFIER;
import static org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory.rebuildRestEndpointOptions;
import static org.apache.flink.util.Preconditions.checkNotNull;
/** The base class for sql gateway test. */
public class TestBase {
@RegisterExtension
@Order(1)
private static final MiniClusterExtension MINI_CLUSTER = new MiniClusterExtension();
@RegisterExtension
@Order(2)
protected static final SqlGatewayServiceExtension SQL_GATEWAY_SERVICE_EXTENSION =
new SqlGatewayServiceExtension(MINI_CLUSTER::getClientConfiguration);
@Nullable protected static String targetAddress = null;
@Nullable private static SqlGatewayRestEndpoint sqlGatewayRestEndpoint = null;
protected static int port = 0;
@BeforeAll
static void start() throws Exception {
final String address = InetAddress.getLoopbackAddress().getHostAddress();
Configuration config = getBaseConfig(getFlinkConfig(address, address, "0"));
sqlGatewayRestEndpoint =
new SqlGatewayRestEndpoint(config, SQL_GATEWAY_SERVICE_EXTENSION.getService());
sqlGatewayRestEndpoint.start();
InetSocketAddress serverAddress = checkNotNull(sqlGatewayRestEndpoint.getServerAddress());
targetAddress = serverAddress.getHostName();
port = serverAddress.getPort();
}
@AfterAll
static void stop() throws Exception {
checkNotNull(sqlGatewayRestEndpoint);
sqlGatewayRestEndpoint.close();
}
private static Configuration getBaseConfig(Configuration flinkConf) {
SqlGatewayEndpointFactoryUtils.DefaultEndpointFactoryContext context =
new SqlGatewayEndpointFactoryUtils.DefaultEndpointFactoryContext(
null, flinkConf, getEndpointConfig(flinkConf, IDENTIFIER));
return rebuildRestEndpointOptions(context.getEndpointOptions());
}
private static Configuration getFlinkConfig(
String address, String bindAddress, String portRange) {
final Configuration config = new Configuration();
if (address != null) {
config.setString(
getSqlGatewayRestOptionFullName(SqlGatewayRestOptions.ADDRESS.key()), address);
}
if (bindAddress != null) {
config.setString(
getSqlGatewayRestOptionFullName(SqlGatewayRestOptions.BIND_ADDRESS.key()),
bindAddress);
}
if (portRange != null) {
config.setString(
getSqlGatewayRestOptionFullName(SqlGatewayRestOptions.PORT.key()), portRange);
}
return config;
}
private static String getSqlGatewayRestOptionFullName(String key) {
return getSqlGatewayOptionPrefix(IDENTIFIER) + key;
}
/** A simple {@link Extension} to be used by tests that require a {@link SqlGatewayService}. */
static class SqlGatewayServiceExtension implements BeforeAllCallback, AfterAllCallback {
private SqlGatewayService service;
private SessionManager sessionManager;
private TemporaryFolder temporaryFolder;
private final Supplier<Configuration> configSupplier;
private final Function<DefaultContext, SessionManager> sessionManagerCreator;
public SqlGatewayServiceExtension(Supplier<Configuration> configSupplier) {
this(configSupplier, SessionManager::create);
}
public SqlGatewayServiceExtension(
Supplier<Configuration> configSupplier,
Function<DefaultContext, SessionManager> sessionManagerCreator) {
this.configSupplier = configSupplier;
this.sessionManagerCreator = sessionManagerCreator;
}
@Override
public void beforeAll(ExtensionContext context) throws Exception {
final Map<String, String> originalEnv = System.getenv();
try {
// prepare conf dir
temporaryFolder = new TemporaryFolder();
temporaryFolder.create();
File confFolder = temporaryFolder.newFolder("conf");
File confYaml = new File(confFolder, "flink-conf.yaml");
if (!confYaml.createNewFile()) {
throw new IOException("Can't create testing flink-conf.yaml file.");
}
FileUtils.write(
confYaml,
getFlinkConfContent(configSupplier.get().toMap()),
StandardCharsets.UTF_8);
// adjust the test environment for the purposes of this test
Map<String, String> map = new HashMap<>(System.getenv());
map.put(ENV_FLINK_CONF_DIR, confFolder.getAbsolutePath());
CommonTestUtils.setEnv(map);
sessionManager =
sessionManagerCreator.apply(
DefaultContext.load(
new Configuration(), Collections.emptyList(), true, false));
} finally {
CommonTestUtils.setEnv(originalEnv);
}
service = new SqlGatewayServiceImpl(sessionManager);
sessionManager.start();
}
@Override
public void afterAll(ExtensionContext context) throws Exception {
if (sessionManager != null) {
sessionManager.stop();
}
temporaryFolder.delete();
}
public SqlGatewayService getService() {
return service;
}
private String getFlinkConfContent(Map<String, String> flinkConf) {
StringBuilder sb = new StringBuilder();
flinkConf.forEach((k, v) -> sb.append(k).append(": ").append(v).append("\n"));
return sb.toString();
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/executor/FlinkSqlGatewayExecutorTest.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/executor/FlinkSqlGatewayExecutorTest.java | /*
* 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.engine.flink.sql.gataway.executor;
import org.apache.paimon.web.engine.flink.common.result.ExecutionResult;
import org.apache.paimon.web.engine.flink.common.result.FetchResultParams;
import org.apache.paimon.web.engine.flink.sql.gataway.TestBase;
import org.apache.paimon.web.engine.flink.sql.gateway.client.SqlGatewayClient;
import org.apache.paimon.web.engine.flink.sql.gateway.executor.FlinkSqlGatewayExecutor;
import org.apache.paimon.web.engine.flink.sql.gateway.model.SessionEntity;
import org.apache.calcite.sql.parser.SqlParseException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/** Test for {@link FlinkSqlGatewayExecutor}. */
public class FlinkSqlGatewayExecutorTest extends TestBase {
SqlGatewayClient client;
SessionEntity session;
FlinkSqlGatewayExecutor executor;
private static final String SESSION_NAME = "test_session";
@BeforeEach
void before() throws Exception {
client = new SqlGatewayClient(targetAddress, port);
session = client.openSession(SESSION_NAME);
executor = new FlinkSqlGatewayExecutor(session);
}
@Test
public void testExecuteSql() throws Exception {
ExecutionResult executionResult = executor.executeSql(StatementsConstant.statement, 0);
assertNotNull(executionResult);
assertNotNull(executionResult.getJobId());
}
@Test
public void testExecuteStatementSetSql() throws Exception {
ExecutionResult executionResult =
executor.executeSql(StatementsConstant.statementSetSql, 0);
assertNotNull(executionResult);
assertNotNull(executionResult.getJobId());
}
@Test
public void testExecutorStatementWithoutResult() throws Exception {
ExecutionResult executionResult =
executor.executeSql(StatementsConstant.createStatement, 0);
assertNull(executionResult);
}
@Test
public void testExecuteDQLStatementWithPendingInsertStatements() {
Exception exception =
assertThrows(
UnsupportedOperationException.class,
() -> {
executor.executeSql(
StatementsConstant.selectStatementWithPendingInsertStatements,
0);
});
String expectedMessage = "Cannot execute DQL statement with pending INSERT statements.";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void testExecuteBadSqlStatement() {
Exception exception =
assertThrows(
SqlParseException.class,
() -> {
executor.executeSql(StatementsConstant.badStatement, 0);
});
String expectedMessage = "Non-query expression encountered in illegal context";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
}
@Test
public void testFetchResults() throws Exception {
ExecutionResult executionResult =
executor.executeSql(StatementsConstant.selectStatement, 10);
assertNotNull(executionResult);
assertNotNull(executionResult.getJobId());
assertNotNull(executionResult.getSubmitId());
assertTrue(executionResult.shouldFetchResult());
FetchResultParams params =
FetchResultParams.builder()
.sessionId(session.getSessionId())
.submitId(executionResult.getSubmitId())
.token(1L)
.build();
ExecutionResult fetchResult = executor.fetchResults(params);
assertFalse(fetchResult.getData().isEmpty());
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/executor/StatementsConstant.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/executor/StatementsConstant.java | /*
* 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.engine.flink.sql.gataway.executor;
/** Statements constant. */
public class StatementsConstant {
public static String statement =
"CREATE TABLE IF NOT EXISTS t_order(\n"
+ " `order_id` BIGINT,\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "CREATE TABLE IF NOT EXISTS sink_table(\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` TIMESTAMP(3),\n"
+ " `one_minute_sum` BIGINT\n"
+ ") WITH('connector' = 'print');\n"
+ "\n"
+ "INSERT INTO\n"
+ " sink_table\n"
+ "SELECT\n"
+ " product,\n"
+ " amount,\n"
+ " order_time,\n"
+ " 0 as one_minute_sum\n"
+ "FROM\n"
+ " t_order;";
public static String selectStatement =
"CREATE TABLE IF NOT EXISTS t_order(\n"
+ " `order_id` BIGINT,\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "SELECT * FROM t_order;";
public static String selectStatementWithPendingInsertStatements =
"CREATE TABLE IF NOT EXISTS t_order(\n"
+ " `order_id` BIGINT,\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "CREATE TABLE IF NOT EXISTS sink_table(\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` TIMESTAMP(3),\n"
+ " `one_minute_sum` BIGINT\n"
+ ") WITH('connector' = 'print');\n"
+ "\n"
+ "INSERT INTO\n"
+ " sink_table\n"
+ "SELECT\n"
+ " product,\n"
+ " amount,\n"
+ " order_time,\n"
+ " 0 as one_minute_sum\n"
+ "FROM\n"
+ " t_order;\n"
+ "SELECT * FROM t_order LIMIT 10;";
public static String createStatement =
"CREATE TABLE IF NOT EXISTS t_order(\n"
+ " `order_id` BIGINT,\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n";
public static String badStatement =
"CREAT TABLE IF NOT EXISTS t_order(\n"
+ " `order_id` BIGINT,\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n";
public static String statementSetSql =
"CREATE TABLE IF NOT EXISTS t_order(\n"
+ " `order_id` BIGINT,\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "CREATE TABLE IF NOT EXISTS sink_table_01(\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` TIMESTAMP(3),\n"
+ " `one_minute_sum` BIGINT\n"
+ ") WITH('connector' = 'print');\n"
+ "CREATE TABLE IF NOT EXISTS sink_table_02(\n"
+ " `product` BIGINT,\n"
+ " `amount` BIGINT,\n"
+ " `order_time` TIMESTAMP(3),\n"
+ " `one_minute_sum` BIGINT\n"
+ ") WITH('connector' = 'print');\n"
+ "\n"
+ "INSERT INTO\n"
+ " sink_table_01\n"
+ "SELECT\n"
+ " product,\n"
+ " amount,\n"
+ " order_time,\n"
+ " 0 as one_minute_sum\n"
+ "FROM\n"
+ " t_order;\n"
+ "INSERT INTO\n"
+ " sink_table_02\n"
+ "SELECT\n"
+ " product,\n"
+ " amount,\n"
+ " order_time,\n"
+ " 0 as one_minute_sum\n"
+ "FROM\n"
+ " t_order;";
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/client/SqlGatewayClientTest.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/test/java/org/apache/paimon/web/engine/flink/sql/gataway/client/SqlGatewayClientTest.java | /*
* 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.engine.flink.sql.gataway.client;
import org.apache.paimon.web.engine.flink.sql.gataway.TestBase;
import org.apache.paimon.web.engine.flink.sql.gateway.client.SqlGatewayClient;
import org.apache.paimon.web.engine.flink.sql.gateway.model.SessionEntity;
import org.apache.commons.collections.MapUtils;
import org.apache.flink.table.gateway.rest.message.statement.FetchResultsResponseBody;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/** Test for {@link SqlGatewayClient}. */
public class SqlGatewayClientTest extends TestBase {
SqlGatewayClient client;
SessionEntity session;
private static final String SESSION_NAME = "test_session";
@BeforeEach
void before() throws Exception {
client = new SqlGatewayClient(targetAddress, port);
session = client.openSession(SESSION_NAME);
}
@Test
public void testGetSessionConfig() throws Exception {
Map<String, String> sessionConfig = client.getSessionConfig(session.getSessionId());
assertTrue(MapUtils.isNotEmpty(sessionConfig));
}
@Test
public void testCloseSession() throws Exception {
String status = client.closeSession(session.getSessionId());
assertEquals("CLOSED", status);
}
@Test
public void testExecuteStatement() throws Exception {
String operationHandle = client.executeStatement(session.getSessionId(), "SELECT 1", null);
assertNotNull(operationHandle);
}
@Test
public void testCompleteStatementHints() throws Exception {
List<String> list = client.completeStatementHints(session.getSessionId(), "CREATE TA");
assertFalse(list.isEmpty());
}
@Test
public void testFetchResults() throws Exception {
String operationHandle = client.executeStatement(session.getSessionId(), "SELECT 1", null);
FetchResultsResponseBody fetchResultsResponseBody =
client.fetchResults(session.getSessionId(), operationHandle, 0);
assertNotNull(fetchResultsResponseBody);
assertEquals("PAYLOAD", fetchResultsResponseBody.getResultType().name());
FetchResultsResponseBody fetchResultsResponseBodyNext =
client.fetchResults(session.getSessionId(), operationHandle, 1);
assertNotNull(fetchResultsResponseBodyNext);
assertEquals("EOS", fetchResultsResponseBodyNext.getResultType().name());
}
@Test
public void testGetOperationStatus() throws Exception {
String operationHandle = client.executeStatement(session.getSessionId(), "SELECT 1", null);
String operationStatus = client.getOperationStatus(session.getSessionId(), operationHandle);
assertNotNull(operationStatus);
}
@Test
public void testCancelOperation() throws Exception {
String operationHandle = client.executeStatement(session.getSessionId(), "SELECT 1", null);
String status = client.cancelOperation(session.getSessionId(), operationHandle);
assertEquals("CANCELED", status);
}
@Test
public void testCloseOperation() throws Exception {
String operationHandle = client.executeStatement(session.getSessionId(), "SELECT 1", null);
String status = client.closeOperation(session.getSessionId(), operationHandle);
assertEquals("CLOSED", status);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/model/HeartbeatEntity.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/model/HeartbeatEntity.java | /*
* 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.engine.flink.sql.gateway.model;
import lombok.Builder;
import lombok.Getter;
/** This is a heartbeat entity of the cluster. */
@Builder
@Getter
public class HeartbeatEntity {
private String status;
private Long lastHeartbeat;
private String clusterVersion;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/model/SessionEntity.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/model/SessionEntity.java | /*
* 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.engine.flink.sql.gateway.model;
import lombok.Builder;
import lombok.Getter;
import java.util.Map;
/** The session entity. */
@Builder
@Getter
public class SessionEntity {
private final String sessionId;
private final String sessionName;
private final String host;
private final int port;
private final Map<String, String> properties;
private final int status;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/utils/CollectResultUtil.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/utils/CollectResultUtil.java | /*
* 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.engine.flink.sql.gateway.utils;
import org.apache.paimon.web.engine.flink.common.result.ExecutionResult;
import org.apache.flink.table.data.GenericRowData;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.gateway.rest.serde.ResultInfo;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** Collect result util. */
public class CollectResultUtil {
public static ExecutionResult.Builder collectSqlGatewayResult(ResultInfo resultInfo) {
List<RowData> data = resultInfo.getData();
List<Map<String, Object>> results =
rowDatasToList(resultInfo.getResultSchema().getColumnNames(), data);
return ExecutionResult.builder().data(results);
}
private static List<Map<String, Object>> rowDatasToList(
List<String> columns, List<RowData> rowDataList) {
List<Map<String, Object>> rows = new ArrayList<>();
for (RowData rowData : rowDataList) {
Map<String, Object> map = new LinkedHashMap<>();
for (int i = 0; i < rowData.getArity(); ++i) {
if (rowData instanceof GenericRowData) {
GenericRowData data = (GenericRowData) rowData;
Object field = data.getField(i);
if (Objects.nonNull(field)) {
map.put(columns.get(i), field.toString());
}
} else {
throw new IllegalArgumentException("RowData is not GenericData.");
}
}
rows.add(map);
}
return rows;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/utils/SqlGateWayRestClient.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/utils/SqlGateWayRestClient.java | /*
* 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.engine.flink.sql.gateway.utils;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.rest.FileUpload;
import org.apache.flink.runtime.rest.RestClient;
import org.apache.flink.runtime.rest.messages.EmptyMessageParameters;
import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
import org.apache.flink.runtime.rest.messages.MessageHeaders;
import org.apache.flink.runtime.rest.messages.MessageParameters;
import org.apache.flink.runtime.rest.messages.RequestBody;
import org.apache.flink.runtime.rest.messages.ResponseBody;
import org.apache.flink.runtime.rest.versioning.RestAPIVersion;
import org.apache.flink.util.ConfigurationException;
import org.apache.flink.util.concurrent.Executors;
import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
/** SQL gateway rest client. */
public class SqlGateWayRestClient extends RestClient {
private final String sqlGatewayHost;
private final int sqlGatewayPort;
public SqlGateWayRestClient(String sqlGatewayHost, int sqlGatewayPort)
throws ConfigurationException {
super(new Configuration(), Executors.newDirectExecutorService());
this.sqlGatewayHost = sqlGatewayHost;
this.sqlGatewayPort = sqlGatewayPort;
}
public <
M extends MessageHeaders<R, P, U>,
U extends MessageParameters,
R extends RequestBody,
P extends ResponseBody>
CompletableFuture<P> sendRequest(
M messageHeaders,
U messageParameters,
R request,
Collection<FileUpload> fileUploads,
RestAPIVersion<? extends RestAPIVersion<?>> apiVersion) {
return throwExceptionHandler(
() -> {
try {
return super.sendRequest(
sqlGatewayHost,
sqlGatewayPort,
messageHeaders,
messageParameters,
request,
fileUploads,
apiVersion);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
public <
M extends MessageHeaders<R, P, U>,
U extends MessageParameters,
R extends RequestBody,
P extends ResponseBody>
CompletableFuture<P> sendRequest(M messageHeaders, U messageParameters, R request) {
return throwExceptionHandler(
() -> {
try {
return super.sendRequest(
sqlGatewayHost,
sqlGatewayPort,
messageHeaders,
messageParameters,
request);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
public <
M extends MessageHeaders<R, P, U>,
U extends MessageParameters,
R extends RequestBody,
P extends ResponseBody>
CompletableFuture<P> sendRequest(
M messageHeaders,
U messageParameters,
R request,
Collection<FileUpload> fileUploads) {
return throwExceptionHandler(
() -> {
try {
return super.sendRequest(
sqlGatewayHost,
sqlGatewayPort,
messageHeaders,
messageParameters,
request,
fileUploads);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
public <
M extends MessageHeaders<EmptyRequestBody, P, EmptyMessageParameters>,
P extends ResponseBody>
CompletableFuture<P> sendRequest(M messageHeaders) {
return throwExceptionHandler(
() -> {
try {
return super.sendRequest(sqlGatewayHost, sqlGatewayPort, messageHeaders);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
private <T> T throwExceptionHandler(Supplier<T> func0) {
try {
return func0.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/utils/FlinkSqlStatementSetBuilder.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/utils/FlinkSqlStatementSetBuilder.java | /*
* 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.engine.flink.sql.gateway.utils;
import org.apache.commons.collections.CollectionUtils;
import java.util.List;
/**
* Utility class for building Flink SQL STATEMENT SET strings for batch execution.
*
* <p>This class provides a static method to construct a STATEMENT SET from a list of individual
* INSERT statements. If there is only one INSERT statement, it returns the statement as is. For
* multiple statements, it wraps them in a Flink SQL EXECUTE STATEMENT SET block.
*/
public class FlinkSqlStatementSetBuilder {
private static final String EXECUTE_STATEMENT_SET = "EXECUTE STATEMENT SET\n";
private static final String BEGIN_STATEMENT = "BEGIN\n";
private static final String END_STATEMENT = "END;\n";
private static final String STATEMENT_DELIMITER = ";\n";
public static String buildStatementSet(List<String> insertStatements) {
StringBuilder statementSetBuilder = new StringBuilder();
if (CollectionUtils.isNotEmpty(insertStatements)) {
if (insertStatements.size() > 1) {
statementSetBuilder.append(EXECUTE_STATEMENT_SET);
statementSetBuilder.append(BEGIN_STATEMENT);
for (String insertStatement : insertStatements) {
statementSetBuilder.append(insertStatement);
statementSetBuilder.append(STATEMENT_DELIMITER);
}
statementSetBuilder.append(END_STATEMENT);
} else {
statementSetBuilder.append(insertStatements.get(0));
statementSetBuilder.append(STATEMENT_DELIMITER);
}
}
return statementSetBuilder.toString();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java | /*
* 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.engine.flink.sql.gateway.executor;
import org.apache.paimon.web.engine.flink.common.executor.Executor;
import org.apache.paimon.web.engine.flink.common.operation.FlinkSqlOperationType;
import org.apache.paimon.web.engine.flink.common.parser.CustomSqlParser;
import org.apache.paimon.web.engine.flink.common.result.ExecutionResult;
import org.apache.paimon.web.engine.flink.common.result.FetchResultParams;
import org.apache.paimon.web.engine.flink.common.status.JobStatus;
import org.apache.paimon.web.engine.flink.sql.gateway.client.SqlGatewayClient;
import org.apache.paimon.web.engine.flink.sql.gateway.model.SessionEntity;
import org.apache.paimon.web.engine.flink.sql.gateway.utils.CollectResultUtil;
import org.apache.paimon.web.engine.flink.sql.gateway.utils.FlinkSqlStatementSetBuilder;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlNodeList;
import org.apache.flink.api.common.JobID;
import org.apache.flink.table.gateway.api.results.ResultSet;
import org.apache.flink.table.gateway.rest.message.statement.FetchResultsResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** The flink sql gateway implementation of the {@link Executor}. */
public class FlinkSqlGatewayExecutor implements Executor {
private static final Long DEFAULT_FETCH_TOKEN = 0L;
private static final String STOP_JOB_BASE_SQL = "STOP JOB '%s'";
private static final String WITH_SAVEPOINT = " WITH SAVEPOINT";
private final SqlGatewayClient client;
private final SessionEntity session;
public FlinkSqlGatewayExecutor(SessionEntity session) throws Exception {
this.session = session;
this.client = new SqlGatewayClient(session.getHost(), session.getPort());
}
@Override
public ExecutionResult executeSql(String multiStatement, int maxRows) throws Exception {
CustomSqlParser customSqlParser = new CustomSqlParser(multiStatement, maxRows);
SqlNodeList sqlNodeList = customSqlParser.parseStmtList();
List<String> insertStatements = new ArrayList<>();
ExecutionResult executionResult = null;
for (SqlNode sqlNode : sqlNodeList) {
FlinkSqlOperationType operationType =
FlinkSqlOperationType.getOperationType(sqlNode.toString());
if (operationType == null) {
String operationTypeString = extractSqlOperationType(sqlNode.toString());
throw new UnsupportedOperationException(
"Unsupported operation type: " + operationTypeString);
}
switch (operationType.getCategory()) {
case DQL:
if (!insertStatements.isEmpty()) {
throw new UnsupportedOperationException(
"Cannot execute DQL statement with pending INSERT statements.");
}
executionResult = executeDqlStatement(sqlNode.toString(), operationType);
break;
case DML:
if (operationType.getType().equals(FlinkSqlOperationType.INSERT.getType())) {
insertStatements.add(sqlNode.toString());
} else {
executionResult = executeDmlStatement(sqlNode.toString());
}
break;
default:
client.executeStatement(session.getSessionId(), sqlNode.toString(), null);
break;
}
if (executionResult != null) {
return executionResult;
}
}
if (!insertStatements.isEmpty()) {
String combinedStatement =
FlinkSqlStatementSetBuilder.buildStatementSet(insertStatements);
executionResult = executeDmlStatement(combinedStatement);
}
if (executionResult == null) {
executionResult =
new ExecutionResult.Builder()
.shouldFetchResult(false)
.status(JobStatus.FINISHED.getValue())
.build();
}
return executionResult;
}
private ExecutionResult executeDqlStatement(
String statement, FlinkSqlOperationType operationType) throws Exception {
String operationId = client.executeStatement(session.getSessionId(), statement, null);
FetchResultsResponseBody results =
client.fetchResults(session.getSessionId(), operationId, DEFAULT_FETCH_TOKEN);
ExecutionResult.Builder builder =
CollectResultUtil.collectSqlGatewayResult(results.getResults())
.submitId(operationId);
JobID jobId = results.getJobID();
if (jobId != null
&& operationType.getType().equals(FlinkSqlOperationType.SELECT.getType())) {
builder.jobId(jobId.toString()).shouldFetchResult(true);
} else if (jobId == null) {
builder.shouldFetchResult(false).status(JobStatus.FINISHED.getValue());
}
return builder.build();
}
private ExecutionResult executeDmlStatement(String statement) throws Exception {
String operationId = client.executeStatement(session.getSessionId(), statement, null);
FetchResultsResponseBody results =
client.fetchResults(session.getSessionId(), operationId, DEFAULT_FETCH_TOKEN);
return new ExecutionResult.Builder()
.submitId(operationId)
.jobId(getJobIdFromResults(results))
.build();
}
private String getJobIdFromResults(FetchResultsResponseBody results) {
return Objects.requireNonNull(results.getJobID(), "Job ID not found in results").toString();
}
@Override
public ExecutionResult fetchResults(FetchResultParams params) throws Exception {
FetchResultsResponseBody fetchResultsResponseBody =
client.fetchResults(params.getSessionId(), params.getSubmitId(), params.getToken());
ResultSet.ResultType resultType = fetchResultsResponseBody.getResultType();
if (resultType == ResultSet.ResultType.EOS) {
return ExecutionResult.builder().shouldFetchResult(false).build();
}
ExecutionResult.Builder builder =
CollectResultUtil.collectSqlGatewayResult(fetchResultsResponseBody.getResults());
builder.submitId(params.getSubmitId());
return builder.build();
}
@Override
public void stop(String jobId, boolean withSavepoint) throws Exception {
StringBuilder sqlBuilder = new StringBuilder(String.format(STOP_JOB_BASE_SQL, jobId));
if (withSavepoint) {
sqlBuilder.append(WITH_SAVEPOINT);
}
client.executeStatement(session.getSessionId(), sqlBuilder.toString(), null);
}
private String extractSqlOperationType(String sql) {
Pattern pattern = Pattern.compile("^(\\w+)");
Matcher matcher = pattern.matcher(sql);
if (matcher.find()) {
return matcher.group(1);
}
return "UNKNOWN";
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutorFactory.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutorFactory.java | /*
* 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.engine.flink.sql.gateway.executor;
import org.apache.paimon.web.engine.flink.common.executor.Executor;
import org.apache.paimon.web.engine.flink.common.executor.ExecutorFactory;
import org.apache.paimon.web.engine.flink.sql.gateway.model.SessionEntity;
/** Factory to create {@link FlinkSqlGatewayExecutor}. */
public class FlinkSqlGatewayExecutorFactory implements ExecutorFactory {
private final SessionEntity sessionEntity;
public FlinkSqlGatewayExecutorFactory(SessionEntity sessionEntity) {
this.sessionEntity = sessionEntity;
}
@Override
public Executor createExecutor() throws Exception {
return new FlinkSqlGatewayExecutor(sessionEntity);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/client/SqlGatewayClient.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/client/SqlGatewayClient.java | /*
* 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.engine.flink.sql.gateway.client;
import org.apache.paimon.web.engine.flink.common.status.HeartbeatStatus;
import org.apache.paimon.web.engine.flink.sql.gateway.model.HeartbeatEntity;
import org.apache.paimon.web.engine.flink.sql.gateway.model.SessionEntity;
import org.apache.paimon.web.engine.flink.sql.gateway.utils.SqlGateWayRestClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.runtime.rest.messages.EmptyMessageParameters;
import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
import org.apache.flink.table.gateway.api.operation.OperationHandle;
import org.apache.flink.table.gateway.api.results.ResultSet;
import org.apache.flink.table.gateway.api.session.SessionHandle;
import org.apache.flink.table.gateway.rest.header.operation.CancelOperationHeaders;
import org.apache.flink.table.gateway.rest.header.operation.CloseOperationHeaders;
import org.apache.flink.table.gateway.rest.header.operation.GetOperationStatusHeaders;
import org.apache.flink.table.gateway.rest.header.session.CloseSessionHeaders;
import org.apache.flink.table.gateway.rest.header.session.ConfigureSessionHeaders;
import org.apache.flink.table.gateway.rest.header.session.GetSessionConfigHeaders;
import org.apache.flink.table.gateway.rest.header.session.OpenSessionHeaders;
import org.apache.flink.table.gateway.rest.header.session.TriggerSessionHeartbeatHeaders;
import org.apache.flink.table.gateway.rest.header.statement.CompleteStatementHeaders;
import org.apache.flink.table.gateway.rest.header.statement.ExecuteStatementHeaders;
import org.apache.flink.table.gateway.rest.header.statement.FetchResultsHeaders;
import org.apache.flink.table.gateway.rest.header.util.GetInfoHeaders;
import org.apache.flink.table.gateway.rest.message.operation.OperationMessageParameters;
import org.apache.flink.table.gateway.rest.message.session.ConfigureSessionRequestBody;
import org.apache.flink.table.gateway.rest.message.session.GetSessionConfigResponseBody;
import org.apache.flink.table.gateway.rest.message.session.OpenSessionRequestBody;
import org.apache.flink.table.gateway.rest.message.session.SessionMessageParameters;
import org.apache.flink.table.gateway.rest.message.statement.CompleteStatementRequestBody;
import org.apache.flink.table.gateway.rest.message.statement.ExecuteStatementRequestBody;
import org.apache.flink.table.gateway.rest.message.statement.FetchResultsMessageParameters;
import org.apache.flink.table.gateway.rest.message.statement.FetchResultsResponseBody;
import org.apache.flink.table.gateway.rest.message.util.GetInfoResponseBody;
import org.apache.flink.table.gateway.rest.util.RowFormat;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* The client of flink sql gateway provides some operations of flink sql gateway. such as creating
* session, execute statement, fetch result, etc.
*/
@Slf4j
public class SqlGatewayClient implements HeartbeatAction {
private static final String DEFAULT_SESSION_NAME_PREFIX = "FLINK_SQL_GATEWAY_SESSION";
private static final int REQUEST_WAITE_TIME = 1000;
private static final int ACTIVE_STATUS = 1;
private final SqlGateWayRestClient restClient;
private final String sqlGatewayHost;
private final int sqlGatewayPort;
public SqlGatewayClient(String sqlGatewayHost, int sqlGatewayPort) throws Exception {
this.sqlGatewayHost = sqlGatewayHost;
this.sqlGatewayPort = sqlGatewayPort;
this.restClient = new SqlGateWayRestClient(sqlGatewayHost, sqlGatewayPort);
}
public SessionEntity openSession(String sessionName) throws Exception {
String name =
StringUtils.isBlank(sessionName)
? DEFAULT_SESSION_NAME_PREFIX + "_" + UUID.randomUUID()
: sessionName;
String sessionId =
restClient
.sendRequest(
OpenSessionHeaders.getInstance(),
EmptyMessageParameters.getInstance(),
new OpenSessionRequestBody(name, new HashMap<>()))
.get()
.getSessionHandle();
return SessionEntity.builder()
.sessionId(sessionId)
.sessionName(sessionName)
.host(sqlGatewayHost)
.port(sqlGatewayPort)
.properties(getSessionConfig(sessionId))
.status(ACTIVE_STATUS)
.build();
}
public Map<String, String> getSessionConfig(String sessionId) throws Exception {
GetSessionConfigResponseBody getSessionConfigResponseBody =
restClient
.sendRequest(
GetSessionConfigHeaders.getInstance(),
new SessionMessageParameters(
buildSessionHandleBySessionId(sessionId)),
EmptyRequestBody.getInstance())
.get();
return getSessionConfigResponseBody.getProperties();
}
public void configureSession(String sessionId, String statement, Long timeout)
throws Exception {
ConfigureSessionRequestBody configureSessionRequestBody =
new ConfigureSessionRequestBody(statement, timeout);
restClient
.sendRequest(
ConfigureSessionHeaders.getInstance(),
new SessionMessageParameters(buildSessionHandleBySessionId(sessionId)),
configureSessionRequestBody)
.get();
}
public String closeSession(String sessionId) throws Exception {
return restClient
.sendRequest(
CloseSessionHeaders.getInstance(),
new SessionMessageParameters(buildSessionHandleBySessionId(sessionId)),
EmptyRequestBody.getInstance())
.get()
.getStatus();
}
public void triggerSessionHeartbeat(String sessionId) throws Exception {
restClient
.sendRequest(
TriggerSessionHeartbeatHeaders.getInstance(),
new SessionMessageParameters(buildSessionHandleBySessionId(sessionId)),
EmptyRequestBody.getInstance())
.get();
}
public String executeStatement(String sessionId, String statement, @Nullable Long timeout)
throws Exception {
return restClient
.sendRequest(
ExecuteStatementHeaders.getInstance(),
new SessionMessageParameters(buildSessionHandleBySessionId(sessionId)),
new ExecuteStatementRequestBody(statement, timeout, new HashMap<>()))
.get()
.getOperationHandle();
}
public List<String> completeStatementHints(String sessionId, String statement)
throws Exception {
return restClient
.sendRequest(
CompleteStatementHeaders.getInstance(),
new SessionMessageParameters(buildSessionHandleBySessionId(sessionId)),
new CompleteStatementRequestBody(statement, statement.length()))
.get()
.getCandidates();
}
public FetchResultsResponseBody fetchResults(String sessionId, String operationId, long token)
throws Exception {
FetchResultsResponseBody fetchResultsResponseBody =
restClient
.sendRequest(
FetchResultsHeaders.getDefaultInstance(),
new FetchResultsMessageParameters(
buildSessionHandleBySessionId(sessionId),
buildOperationHandleByOperationId(operationId),
token,
RowFormat.JSON),
EmptyRequestBody.getInstance())
.get();
ResultSet.ResultType resultType = fetchResultsResponseBody.getResultType();
while (resultType == ResultSet.ResultType.NOT_READY) {
fetchResultsResponseBody =
restClient
.sendRequest(
FetchResultsHeaders.getDefaultInstance(),
new FetchResultsMessageParameters(
buildSessionHandleBySessionId(sessionId),
buildOperationHandleByOperationId(operationId),
token,
RowFormat.JSON),
EmptyRequestBody.getInstance())
.get();
resultType = fetchResultsResponseBody.getResultType();
TimeUnit.MILLISECONDS.sleep(REQUEST_WAITE_TIME);
}
return fetchResultsResponseBody;
}
public String getOperationStatus(String sessionId, String operationId) throws Exception {
return restClient
.sendRequest(
GetOperationStatusHeaders.getInstance(),
new OperationMessageParameters(
buildSessionHandleBySessionId(sessionId),
buildOperationHandleByOperationId(operationId)),
EmptyRequestBody.getInstance())
.get()
.getStatus();
}
public String cancelOperation(String sessionId, String operationId) throws Exception {
return restClient
.sendRequest(
CancelOperationHeaders.getInstance(),
new OperationMessageParameters(
buildSessionHandleBySessionId(sessionId),
buildOperationHandleByOperationId(operationId)),
EmptyRequestBody.getInstance())
.get()
.getStatus();
}
public String closeOperation(String sessionId, String operationId) throws Exception {
return restClient
.sendRequest(
CloseOperationHeaders.getInstance(),
new OperationMessageParameters(
buildSessionHandleBySessionId(sessionId),
buildOperationHandleByOperationId(operationId)),
EmptyRequestBody.getInstance())
.get()
.getStatus();
}
private SessionHandle buildSessionHandleBySessionId(String sessionId) {
return new SessionHandle(UUID.fromString(sessionId));
}
private OperationHandle buildOperationHandleByOperationId(String operationId) {
return new OperationHandle(UUID.fromString(operationId));
}
@Override
public HeartbeatEntity checkClusterHeartbeat() {
try {
GetInfoResponseBody heartbeat =
restClient
.sendRequest(
GetInfoHeaders.getInstance(),
EmptyMessageParameters.getInstance(),
EmptyRequestBody.getInstance())
.get();
if (Objects.nonNull(heartbeat)) {
return HeartbeatEntity.builder()
.lastHeartbeat(System.currentTimeMillis())
.status(HeartbeatStatus.ACTIVE.name())
.clusterVersion(heartbeat.getProductVersion())
.build();
}
} catch (Exception exec) {
log.error(
"An exception occurred while obtaining the cluster status :{}",
exec.getMessage(),
exec);
return this.buildResulHeartbeatEntity(HeartbeatStatus.UNREACHABLE);
}
return this.buildResulHeartbeatEntity(HeartbeatStatus.UNKNOWN);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/client/SessionClusterClient.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/client/SessionClusterClient.java | /*
* 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.engine.flink.sql.gateway.client;
import org.apache.paimon.web.engine.flink.common.status.HeartbeatStatus;
import org.apache.paimon.web.engine.flink.sql.gateway.model.HeartbeatEntity;
import org.apache.paimon.web.engine.flink.sql.gateway.utils.SqlGateWayRestClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.flink.runtime.rest.handler.legacy.messages.ClusterOverviewWithVersion;
import org.apache.flink.runtime.rest.messages.ClusterOverviewHeaders;
import org.apache.flink.runtime.rest.messages.EmptyMessageParameters;
import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
import java.util.Objects;
/**
* The flink session client provides some operations on the flink session cluster, such as obtaining
* the cluster status. etc. The flink client implementation of the {@link HeartbeatAction}.
*/
@Slf4j
public class SessionClusterClient implements HeartbeatAction {
private final SqlGateWayRestClient restClient;
public SessionClusterClient(String sessionClusterHost, int sessionClusterPort)
throws Exception {
this.restClient = new SqlGateWayRestClient(sessionClusterHost, sessionClusterPort);
}
@Override
public HeartbeatEntity checkClusterHeartbeat() {
try {
ClusterOverviewWithVersion heartbeat =
restClient
.sendRequest(
ClusterOverviewHeaders.getInstance(),
EmptyMessageParameters.getInstance(),
EmptyRequestBody.getInstance())
.get();
if (Objects.nonNull(heartbeat)) {
return HeartbeatEntity.builder()
.lastHeartbeat(System.currentTimeMillis())
.status(HeartbeatStatus.ACTIVE.name())
.clusterVersion(heartbeat.getVersion())
.build();
}
} catch (Exception ex) {
log.error(
"An exception occurred while obtaining the cluster status :{}",
ex.getMessage(),
ex);
return this.buildResulHeartbeatEntity(HeartbeatStatus.UNREACHABLE);
}
return this.buildResulHeartbeatEntity(HeartbeatStatus.UNKNOWN);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/client/HeartbeatAction.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/client/HeartbeatAction.java | /*
* 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.engine.flink.sql.gateway.client;
import org.apache.paimon.web.engine.flink.common.status.HeartbeatStatus;
import org.apache.paimon.web.engine.flink.sql.gateway.model.HeartbeatEntity;
/** Using to execute cluster heartbeat action. */
public interface HeartbeatAction {
/**
* Execute cluster action to obtain cluster status.
*
* @return cluster heartbeat entity.
*/
HeartbeatEntity checkClusterHeartbeat();
/**
* Build a heartbeat entity representing an error based on the cluster status. This method is
* used to generate a heartbeat object when the cluster status is abnormal, recording the
* current time and the error status of the cluster.
*
* @param status The current status of the cluster, used to set the status field of the
* heartbeat entity.
* @return Returns a completed heartbeat entity, including the current timestamp and status
* information.
*/
default HeartbeatEntity buildResulHeartbeatEntity(HeartbeatStatus status) {
return HeartbeatEntity.builder().status(status.name()).build();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/CustomSqlParserTest.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/CustomSqlParserTest.java | /*
* 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.engine.flink.common.parser;
import org.apache.calcite.sql.SqlNodeList;
import org.apache.calcite.sql.parser.SqlParseException;
import org.junit.jupiter.api.Test;
import static org.apache.paimon.web.engine.flink.common.parser.StatementsConstant.statement1;
import static org.apache.paimon.web.engine.flink.common.parser.StatementsConstant.statement2;
import static org.apache.paimon.web.engine.flink.common.parser.StatementsConstant.statement3;
import static org.assertj.core.api.Assertions.assertThat;
/** Tests of {@link CustomSqlParser}. */
public class CustomSqlParserTest {
@Test
public void testParse() throws SqlParseException {
CustomSqlParser customSqlParser = new CustomSqlParser(statement1, 0);
SqlNodeList sqlNodeList = customSqlParser.parseStmtList();
assertThat(sqlNodeList.size()).isEqualTo(5);
}
@Test
public void testSelectLimit() throws SqlParseException {
CustomSqlParser customSqlParser = new CustomSqlParser(statement2, 500);
String actual = customSqlParser.parseStmtList().get(2).toString();
assertThat(actual)
.isEqualToIgnoringWhitespace("SELECT * FROM `t_order` FETCH NEXT 500 ROWS ONLY");
}
@Test
public void testSelectWithoutLimit() throws SqlParseException {
CustomSqlParser customSqlParser = new CustomSqlParser(statement3, 200);
String actual = customSqlParser.parseStmtList().get(2).toString();
assertThat(actual).isEqualToIgnoringWhitespace("SELECT COUNT(*) FROM `t_order`");
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementsConstant.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementsConstant.java | /*
* 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.engine.flink.common.parser;
/** Statements constant. */
public class StatementsConstant {
public static String statement1 =
"DROP TABLE IF EXISTS t_order;\n"
+ "CREATE TABLE IF NOT EXISTS t_order(\n"
+ " --order id\n"
+ " `order_id` BIGINT,\n"
+ " --product\n"
+ " `product` BIGINT,\n"
+ " --amount\n"
+ " `amount` BIGINT,\n"
+ " --payment time\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " --WATERMARK\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "-- SELECT * FROM t_order LIMIT 10;\n"
+ "DROP TABLE IF EXISTS sink_table;\n"
+ "CREATE TABLE IF NOT EXISTS sink_table(\n"
+ " --product\n"
+ " `product` BIGINT,\n"
+ " --amount\n"
+ " `amount` BIGINT,\n"
+ " --payment time\n"
+ " `order_time` TIMESTAMP(3),\n"
+ " `one_minute_sum` BIGINT\n"
+ ") WITH('connector' = 'print');\n"
+ "\n"
+ "INSERT INTO\n"
+ " sink_table\n"
+ "SELECT\n"
+ " product,\n"
+ " amount,\n"
+ " order_time,\n"
+ " 0 as one_minute_sum\n"
+ "FROM\n"
+ " t_order;";
public static String statement2 =
"DROP TABLE IF EXISTS t_order;\n"
+ "CREATE TABLE IF NOT EXISTS t_order(\n"
+ " --order id\n"
+ " `order_id` BIGINT,\n"
+ " --product\n"
+ " `product` BIGINT,\n"
+ " --amount\n"
+ " `amount` BIGINT,\n"
+ " --payment time\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " --WATERMARK\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "SELECT * FROM t_order;";
public static String statement3 =
"DROP TABLE IF EXISTS t_order;\n"
+ "CREATE TABLE IF NOT EXISTS t_order(\n"
+ " --order id\n"
+ " `order_id` BIGINT,\n"
+ " --product\n"
+ " `product` BIGINT,\n"
+ " --amount\n"
+ " `amount` BIGINT,\n"
+ " --payment time\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " --WATERMARK\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "SELECT count(*) FROM t_order;";
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementParserTest.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementParserTest.java | /*
* 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.engine.flink.common.parser;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/** Tests of {@link StatementParser}. */
public class StatementParserTest {
private String statement =
"DROP TABLE IF EXISTS t_order;\n"
+ "CREATE TABLE IF NOT EXISTS t_order(\n"
+ " --order id\n"
+ " `order_id` BIGINT,\n"
+ " --product\n"
+ " `product` BIGINT,\n"
+ " --amount\n"
+ " `amount` BIGINT,\n"
+ " --payment time\n"
+ " `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)),\n"
+ " --WATERMARK\n"
+ " WATERMARK FOR order_time AS order_time-INTERVAL '2' SECOND\n"
+ ") WITH(\n"
+ " 'connector' = 'datagen',\n"
+ " 'rows-per-second' = '1',\n"
+ " 'fields.order_id.min' = '1',\n"
+ " 'fields.order_id.max' = '2',\n"
+ " 'fields.amount.min' = '1',\n"
+ " 'fields.amount.max' = '10',\n"
+ " 'fields.product.min' = '1',\n"
+ " 'fields.product.max' = '2'\n"
+ ");\n"
+ "-- SELECT * FROM t_order LIMIT 10;\n"
+ "DROP TABLE IF EXISTS sink_table;\n"
+ "CREATE TABLE IF NOT EXISTS sink_table(\n"
+ " --product\n"
+ " `product` BIGINT,\n"
+ " --amount\n"
+ " `amount` BIGINT,\n"
+ " --payment time\n"
+ " `order_time` TIMESTAMP(3),\n"
+ " `one_minute_sum` BIGINT\n"
+ ") WITH('connector' = 'print');\n"
+ "\n"
+ "INSERT INTO\n"
+ " sink_table\n"
+ "SELECT\n"
+ " product,\n"
+ " amount,\n"
+ " order_time,\n"
+ " 0 as one_minute_sum\n"
+ "FROM\n"
+ " t_order;";
@Test
public void testParse() {
String[] statements = StatementParser.parse(statement);
assertThat(statements.length).isEqualTo(5);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/FlinkSqlOperationType.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/FlinkSqlOperationType.java | /*
* 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.engine.flink.common.operation;
/**
* This enum represents the types of operations that can be performed in Flink SQL. It includes
* operations like SELECT, CREATE, DROP, ALTER, INSERT, etc. Each operation type is associated with
* a string value, and there are methods to compare the operation type with a string, check if the
* operation type is INSERT, and get the operation type from a SQL statement.
*
* <p>Typically, you would use this enum to categorize a SQL statement and perform different actions
* based on the operation type.
*/
public enum FlinkSqlOperationType {
SELECT("SELECT"),
CREATE("CREATE"),
DROP("DROP"),
ALTER("ALTER"),
TRUNCATE("TRUNCATE"),
INSERT("INSERT"),
UPDATE("UPDATE"),
DELETE("DELETE"),
DESC("DESC"),
DESCRIBE("DESCRIBE"),
EXPLAIN("EXPLAIN"),
USE("USE"),
SHOW("SHOW"),
LOAD("LOAD"),
UNLOAD("UNLOAD"),
SET("SET"),
RESET("RESET"),
CALL("CALL");
private String type;
FlinkSqlOperationType(String type) {
this.type = type;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
/**
* Gets the operation type from a SQL statement.
*
* @param sql the SQL statement
* @return the operation type
*/
public static FlinkSqlOperationType getOperationType(String sql) {
String sqlTrim = sql.replaceAll("[\\s\\t\\n\\r]", "").trim().toUpperCase();
for (FlinkSqlOperationType sqlType : FlinkSqlOperationType.values()) {
if (sqlTrim.startsWith(sqlType.getType())) {
return sqlType;
}
}
return null;
}
public SqlCategory getCategory() {
switch (this) {
case CREATE:
case DROP:
case ALTER:
case TRUNCATE:
return SqlCategory.DDL;
case INSERT:
case UPDATE:
case DELETE:
return SqlCategory.DML;
case SELECT:
case DESC:
case DESCRIBE:
case EXPLAIN:
case SHOW:
return SqlCategory.DQL;
default:
return SqlCategory.OTHER;
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/SqlCategory.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/SqlCategory.java | /*
* 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.engine.flink.common.operation;
/** Enum representing the category of SQL statements. */
public enum SqlCategory {
DDL,
DML,
DQL,
OTHER
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/FetchResultParams.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/FetchResultParams.java | /*
* 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.engine.flink.common.result;
/** Represents the parameters required to fetch the results of a certain operation. */
public class FetchResultParams {
private final String sessionId;
private final String submitId;
private final Long token;
private FetchResultParams(String sessionId, String submitId, Long token) {
this.sessionId = sessionId;
this.submitId = submitId;
this.token = token;
}
public String getSessionId() {
return sessionId;
}
public String getSubmitId() {
return submitId;
}
public Long getToken() {
return token;
}
public static Builder builder() {
return new Builder();
}
/** The builder for FetchResultParams. */
public static class Builder {
private String sessionId;
private String submitId;
private Long token;
public Builder sessionId(String sessionId) {
this.sessionId = sessionId;
return this;
}
public Builder submitId(String submitId) {
this.submitId = submitId;
return this;
}
public Builder token(Long token) {
this.token = token;
return this;
}
public FetchResultParams build() {
return new FetchResultParams(sessionId, submitId, token);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/ExecutionResult.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/ExecutionResult.java | /*
* 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.engine.flink.common.result;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/** Represents the outcome of a job execution process. */
public class ExecutionResult implements Serializable {
private static final long serialVersionUID = 1L;
private final String submitId;
private final String jobId;
private final String status;
private final List<Map<String, Object>> data;
private final boolean shouldFetchResult;
private ExecutionResult(
String submitId,
String jobId,
String status,
List<Map<String, Object>> data,
boolean shouldFetchResult) {
this.submitId = submitId;
this.jobId = jobId;
this.status = status;
this.data = data;
this.shouldFetchResult = shouldFetchResult;
}
public String getSubmitId() {
return submitId;
}
public String getJobId() {
return jobId;
}
public String getStatus() {
return status;
}
public List<Map<String, Object>> getData() {
return data;
}
public boolean shouldFetchResult() {
return shouldFetchResult;
}
public static Builder builder() {
return new Builder();
}
/** The builder for SubmitResult. */
public static class Builder {
private String submitId;
private String jobId;
private String status;
private List<Map<String, Object>> data = new ArrayList<>();
private boolean shouldFetchResult;
public Builder submitId(String submitId) {
this.submitId = submitId;
return this;
}
public Builder jobId(String jobId) {
this.jobId = jobId;
return this;
}
public Builder status(String status) {
this.status = status;
return this;
}
public Builder data(List<Map<String, Object>> data) {
this.data = data;
return this;
}
public Builder addData(Map<String, Object> dataItem) {
this.data.add(dataItem);
return this;
}
public Builder shouldFetchResult(boolean shouldFetchResult) {
this.shouldFetchResult = shouldFetchResult;
return this;
}
public ExecutionResult build() {
return new ExecutionResult(submitId, jobId, status, data, shouldFetchResult);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/Executor.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/Executor.java | /*
* 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.engine.flink.common.executor;
import org.apache.paimon.web.engine.flink.common.result.ExecutionResult;
import org.apache.paimon.web.engine.flink.common.result.FetchResultParams;
/**
* The Executor interface provides methods to submit SQL statements for execution, fetch results,
* and stop jobs.
*/
public interface Executor {
/**
* Executes an SQL statement.
*
* @param statement The SQL statement to be executed.
* @param maxRows The maximum number of rows to return in the result set.
* @return SubmitResult containing information about the execution result.
* @throws Exception if there is an error executing the SQL statement.
*/
ExecutionResult executeSql(String statement, int maxRows) throws Exception;
/**
* Fetches the results of a previously submitted SQL statement execution.
*
* @param params The parameters defining how results should be fetched.
* @return SubmitResult containing the execution results.
* @throws Exception if there is an error fetching the results.
*/
ExecutionResult fetchResults(FetchResultParams params) throws Exception;
/**
* Attempts to stop a running job identified by its jobId.
*
* @param jobId The unique identifier of the job to stop.
* @param withSavepoint If true, the job will create a savepoint before stopping.
* @throws Exception if the job cannot be stopped or savepoint cannot be created.
*/
void stop(String jobId, boolean withSavepoint) throws Exception;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/ExecutorFactory.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/ExecutorFactory.java | /*
* 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.engine.flink.common.executor;
/** Factory to create {@link Executor}. */
public interface ExecutorFactory {
/**
* Creates a new {@link Executor}.
*
* @return A new instance of {@link Executor}
* @throws Exception if executor creation fails
*/
Executor createExecutor() throws Exception;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/HeartbeatStatus.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/HeartbeatStatus.java | /*
* 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.engine.flink.common.status;
/** This enum represents the status of a cluster heartbeat. */
public enum HeartbeatStatus {
/** * The cluster is active. */
ACTIVE,
/** Unable to connect to the target machine, usually due to network anomalies. */
UNREACHABLE,
/**
* The cluster is in an unknown state, usually due to a cluster don't result heartbeat
* information, but its network is normal.
*/
UNKNOWN,
/**
* The cluster is dead, usually due to a cluster don't obtain heartbeat information for a long
* time.
*/
DEAD;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/JobStatus.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/JobStatus.java | /*
* 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.engine.flink.common.status;
/** Represents the various states that a job. */
public enum JobStatus {
CREATED("CREATED"),
RUNNING("RUNNING"),
FINISHED("FINISHED"),
FAILED("FAILED"),
CANCELED("CANCELED");
private final String value;
public static JobStatus fromValue(String value) {
for (JobStatus type : values()) {
if (type.getValue().equals(value)) {
return type;
}
}
throw new IllegalArgumentException("Unknown job status: " + value);
}
JobStatus(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/CustomSqlParser.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/CustomSqlParser.java | /*
* 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.engine.flink.common.parser;
import org.apache.calcite.config.Lex;
import org.apache.calcite.sql.SqlIdentifier;
import org.apache.calcite.sql.SqlLiteral;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlNodeList;
import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.parser.SqlParseException;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.flink.sql.parser.impl.FlinkSqlParserImpl;
import org.apache.flink.sql.parser.validate.FlinkSqlConformance;
/** CustomSqlParser to parse Sql list. */
public class CustomSqlParser {
private static final SqlParser.Config config;
private final SqlParser parser;
private final int limit;
static {
config =
SqlParser.config()
.withParserFactory(FlinkSqlParserImpl.FACTORY)
.withConformance(FlinkSqlConformance.DEFAULT)
.withLex(Lex.JAVA)
.withIdentifierMaxLength(256);
}
public CustomSqlParser(String sql, int limit) {
this.parser = SqlParser.create(sql, config);
this.limit = limit;
}
public SqlNodeList parseStmtList() throws SqlParseException {
SqlNodeList nodeList = parser.parseStmtList();
for (SqlNode node : nodeList) {
if (node instanceof SqlSelect) {
SqlSelect select = (SqlSelect) node;
if (!hasAggregateOrGroupBy(select) && select.getFetch() == null) {
SqlLiteral sqlLiteral =
SqlLiteral.createExactNumeric(String.valueOf(limit), SqlParserPos.ZERO);
select.setFetch(sqlLiteral);
}
}
}
return nodeList;
}
private boolean hasAggregateOrGroupBy(SqlSelect select) {
if (select.getGroup() != null && !select.getGroup().isEmpty()) {
return true;
}
return containsComplexOperations(select.getSelectList());
}
private boolean containsComplexOperations(SqlNodeList nodes) {
if (nodes != null) {
for (SqlNode node : nodes) {
if (!(node instanceof SqlIdentifier)) {
return true;
}
}
}
return false;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/StatementParser.java | paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/StatementParser.java | /*
* 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.engine.flink.common.parser;
import java.util.Arrays;
/** The parser of the SQL statement. */
public class StatementParser {
private static final String STATEMENT_SPLIT = ";\n";
public static String[] parse(String statement) {
if (statement == null || statement.trim().isEmpty()) {
return new String[0];
}
String[] splits = statement.replace(";\r\n", ";\n").split(STATEMENT_SPLIT);
String lastStmt = splits[splits.length - 1].trim();
if (lastStmt.endsWith(";")) {
splits[splits.length - 1] = lastStmt.substring(0, lastStmt.length() - 1).trim();
}
for (int i = 0; i < splits.length; i++) {
splits[i] = splits[i].replaceAll("(?m)^[ \t]*--.*$(\r\n|\n)?", "").trim();
}
return Arrays.stream(splits).filter(s -> !s.isEmpty()).toArray(String[]::new);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/test/java/org/apache/paimon/web/api/catalog/PaimonServiceTest.java | paimon-web-api/src/test/java/org/apache/paimon/web/api/catalog/PaimonServiceTest.java | /*
* 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.api.catalog;
import org.apache.paimon.table.Table;
import org.apache.paimon.types.DataType;
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.TableChange;
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;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/** The test class of catalog creator in {@link PaimonService}. */
public class PaimonServiceTest {
private String warehouse;
private PaimonService service;
@TempDir private Path tempFile;
private final String db = "test_default_db";
@BeforeEach
public void before() {
warehouse = tempFile.toUri().toString();
service =
PaimonServiceFactory.createFileSystemCatalogService(
"paimon", warehouse, new HashMap<>());
service.createDatabase(db);
}
@AfterEach
public void after() {
if (service.databaseExists(db)) {
service.dropDatabase(db);
}
}
@Test
public void testDatabaseExists() {
boolean exists = service.databaseExists(db);
assertThat(exists).isTrue();
}
@Test
public void testListDatabase() {
service.createDatabase("db1");
List<String> databases = service.listDatabases();
assertThat(databases).contains("test_default_db", "db1");
dropDatabase("db1");
}
@Test
public void testCreateDatabase() {
service.createDatabase("test_db");
boolean exists = service.databaseExists("test_db");
assertThat(exists).isTrue();
assertThatExceptionOfType(DatabaseException.DatabaseAlreadyExistsException.class)
.isThrownBy(() -> service.createDatabase("test_db"))
.withMessage("The database 'test_db' already exists in the catalog.");
dropDatabase("test_db");
}
@Test
public void testDropDatabase() {
service.createDatabase("db2");
boolean exists = service.databaseExists("db2");
assertThat(exists).isTrue();
service.dropDatabase("db2");
boolean notExist = service.databaseExists("db2");
assertThat(notExist).isFalse();
}
@Test
public void testTableExists() {
createTable(db, "tb1");
boolean exists = service.tableExists(db, "tb1");
boolean notExists = service.tableExists(db, "tb_not");
assertThat(exists).isTrue();
assertThat(notExists).isFalse();
}
@Test
public void testListTables() {
createTable(db, "tb1");
createTable(db, "tb2");
List<String> tables = service.listTables(db);
assertThat(tables).contains("tb1", "tb2");
}
@Test
public void testCreateTable() {
createTable(db, "tb1");
boolean exists = service.tableExists(db, "tb1");
assertThat(exists).isTrue();
assertThatExceptionOfType(TableException.TableAlreadyExistException.class)
.isThrownBy(() -> createTable(db, "tb1"))
.withMessage("The table 'tb1' already exists in the database.");
assertThatExceptionOfType(DatabaseException.DatabaseNotExistException.class)
.isThrownBy(() -> createTable("db1", "tb1"))
.withMessage("The database 'db1' does not exist in the catalog.");
}
@Test
public void testGetTable() {
createTable(db, "tb1");
Table tb1 = service.getTable(db, "tb1");
assertThat(tb1).isInstanceOf(Table.class);
assertThat(tb1.name()).isEqualTo("tb1");
assertThatExceptionOfType(TableException.TableNotExistException.class)
.isThrownBy(() -> service.getTable(db, "tb2"))
.withMessage("The table 'tb2' does not exist in the database.");
}
@Test
public void testRenameTable() {
createTable(db, "tb1");
createTable(db, "tb3");
createTable(db, "tb4");
createTable(db, "tb6");
assertThat(service.tableExists(db, "tb1")).isTrue();
service.renameTable(db, "tb1", "tb2");
assertThat(service.tableExists(db, "tb1")).isFalse();
assertThat(service.tableExists(db, "tb2")).isTrue();
assertThatExceptionOfType(TableException.TableAlreadyExistException.class)
.isThrownBy(() -> service.renameTable(db, "tb3", "tb4"))
.withMessage("The table 'tb4' already exists in the database.");
assertThatExceptionOfType(TableException.TableNotExistException.class)
.isThrownBy(() -> service.renameTable(db, "tb5", "tb7"))
.withMessage("The table 'tb5' does not exist in the database.");
}
@Test
public void testDropTable() {
createTable(db, "tb1");
assertThat(service.tableExists(db, "tb1")).isTrue();
service.dropTable(db, "tb1");
assertThat(service.tableExists(db, "tb1")).isFalse();
assertThatExceptionOfType(TableException.TableNotExistException.class)
.isThrownBy(() -> service.dropTable(db, "tb5"))
.withMessage("The table 'tb5' does not exist in the database.");
}
@Test
public void testAddColumn() {
createTable(db, "tb1");
ColumnMetadata age = new ColumnMetadata("age", DataTypes.INT());
TableChange.ColumnPosition columnPosition = TableChange.ColumnPosition.after("id");
TableChange.AddColumn add = TableChange.add(age, columnPosition);
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(add);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
List<String> fieldNames = tb1.rowType().getFieldNames();
assertThat(fieldNames).contains("id", "age", "name");
}
@Test
public void testModifyColumnType() {
createTable(db, "tb1");
ColumnMetadata id = new ColumnMetadata("id", DataTypes.INT());
TableChange.ModifyColumnType modifyColumnType =
TableChange.modifyColumnType(id, DataTypes.BIGINT());
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(modifyColumnType);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
List<DataType> fieldTypes = tb1.rowType().getFieldTypes();
assertThat(fieldTypes).contains(DataTypes.BIGINT(), DataTypes.STRING());
}
@Test
public void testModifyColumnName() {
createTable(db, "tb1");
ColumnMetadata id = new ColumnMetadata("id", DataTypes.INT());
TableChange.ModifyColumnName modifyColumnName = TableChange.modifyColumnName(id, "age");
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(modifyColumnName);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
List<String> fieldNames = tb1.rowType().getFieldNames();
assertThat(fieldNames).contains("age", "name");
}
@Test
public void testModifyColumnComment() {
createTable(db, "tb1");
ColumnMetadata id = new ColumnMetadata("id", DataTypes.INT());
TableChange.ModifyColumnComment modifyColumnComment =
TableChange.modifyColumnComment(id, "id");
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(modifyColumnComment);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
String description = tb1.rowType().getFields().get(0).description();
assertThat(description).isEqualTo("id");
}
@Test
public void testModifyColumnPosition() {
createTable(db, "tb1");
ColumnMetadata name = new ColumnMetadata("name", DataTypes.STRING());
TableChange.ColumnPosition columnPosition = TableChange.ColumnPosition.first();
TableChange.ModifyColumnPosition modifyColumnPosition =
TableChange.modifyColumnPosition(name, columnPosition);
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(modifyColumnPosition);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
String columnName = tb1.rowType().getFields().get(0).name();
assertThat(columnName).isEqualTo("name");
}
@Test
public void testDropColumn() {
createTable(db, "tb1");
TableChange.DropColumn dropColumn = TableChange.dropColumn("id");
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(dropColumn);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
List<String> fieldNames = tb1.rowType().getFieldNames();
assertThat(fieldNames).contains("name");
assertThat(fieldNames).doesNotContain("id");
}
@Test
public void testSetOption() {
createTable(db, "tb1");
TableChange.SetOption setOption = TableChange.set("bucket", "2");
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(setOption);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
String bucket = tb1.options().get("bucket");
assertThat(bucket).isEqualTo("2");
}
@Test
public void testRemoveOption() {
createTable(db, "tb1");
TableChange.SetOption setOption = TableChange.set("bucket", "2");
List<TableChange> tableChanges = new ArrayList<>();
tableChanges.add(setOption);
service.alterTable(db, "tb1", tableChanges);
Table tb1 = service.getTable(db, "tb1");
String bucket = tb1.options().get("bucket");
assertThat(bucket).isEqualTo("2");
TableChange.RemoveOption resetOption = TableChange.remove("bucket");
List<TableChange> changes = new ArrayList<>();
changes.add(resetOption);
service.alterTable(db, "tb1", changes);
Table tb = service.getTable(db, "tb1");
assertThat(tb.options().get("bucket")).isEqualTo(null);
}
private void createTable(String databaseName, String tableName) {
List<ColumnMetadata> columns = new ArrayList<>();
ColumnMetadata id = new ColumnMetadata("id", DataTypes.INT());
ColumnMetadata name = new ColumnMetadata("name", DataTypes.STRING());
columns.add(id);
columns.add(name);
TableMetadata tableMetadata = TableMetadata.builder().columns(columns).build();
service.createTable(databaseName, tableName, tableMetadata);
}
private void dropDatabase(String databaseName) {
if (service.databaseExists(databaseName)) {
service.dropDatabase(databaseName);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/FlinkCdcActionContextTestBase.java | paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/FlinkCdcActionContextTestBase.java | /*
* 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.api.action.context;
/** FlinkCdcActionContextTestBase. */
public class FlinkCdcActionContextTestBase {
protected static final String WAREHOUSE = "warehouse";
protected static final String DATABASE = "database";
protected static final String TABLE = "table";
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/MysqlSyncTableActionContextTest.java | paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/MysqlSyncTableActionContextTest.java | /*
* 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.api.action.context;
import org.apache.paimon.web.api.exception.ActionException;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertLinesMatch;
import static org.junit.jupiter.api.Assertions.assertThrows;
/** The test class of mysql sync table action context in {@link MysqlSyncTableActionContext}. */
public class MysqlSyncTableActionContextTest extends FlinkCdcActionContextTestBase {
@Test
public void testBuild() {
List<String> args =
MysqlSyncTableActionContext.builder()
.warehouse(WAREHOUSE)
.database(DATABASE)
.table(TABLE)
.build()
.getArguments();
List<String> expectedArgs =
Arrays.asList(
"mysql_sync_table",
"--warehouse",
WAREHOUSE,
"--database",
DATABASE,
"--table",
TABLE);
assertLinesMatch(expectedArgs, args);
}
@Test
public void testBuildConf() {
List<String> args =
MysqlSyncTableActionContext.builder()
.warehouse(WAREHOUSE)
.database(DATABASE)
.table(TABLE)
.partitionKeys("pt")
.mysqlConfList(
Arrays.asList(
"table-name='source_table'",
"database-name='source_db'",
"password=123456"))
.catalogConfList(
Arrays.asList("metastore=hive", "uri=thrift://hive-metastore:9083"))
.tableConfList(Arrays.asList("bucket=4", "changelog-producer=input"))
.build()
.getArguments();
List<String> expectedCommands =
Arrays.asList(
"mysql_sync_table",
"--warehouse",
WAREHOUSE,
"--database",
DATABASE,
"--table",
TABLE,
"--partition_keys",
"pt",
"--catalog_conf",
"metastore=hive",
"--catalog_conf",
"uri=thrift://hive-metastore:9083",
"--table_conf",
"bucket=4",
"--table_conf",
"changelog-producer=input",
"--mysql_conf",
"table-name='source_table'",
"--mysql_conf",
"database-name='source_db'",
"--mysql_conf",
"password=123456");
assertLinesMatch(expectedCommands, args);
}
@Test
public void testBuildError() {
MysqlSyncTableActionContext context =
MysqlSyncTableActionContext.builder()
.warehouse(WAREHOUSE)
.database(DATABASE)
.partitionKeys("pt")
.primaryKeys("pt,uid")
.mysqlConfList(
Arrays.asList(
"table-name='source_table'",
"database-name='source_db'",
"password=123456"))
.catalogConfList(
Arrays.asList("metastore=hive", "uri=thrift://hive-metastore:9083"))
.tableConfList(Arrays.asList("bucket=4", "changelog-producer=input"))
.build();
ActionException actionException =
assertThrows(ActionException.class, context::getArguments);
assertEquals("table can not be null", actionException.getMessage());
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/MysqlSyncDatabaseActionContextTest.java | paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/MysqlSyncDatabaseActionContextTest.java | /*
* 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.api.action.context;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertLinesMatch;
/**
* The test class of mysql sync databases action context in {@link MysqlSyncDatabaseActionContext}.
*/
public class MysqlSyncDatabaseActionContextTest extends FlinkCdcActionContextTestBase {
@Test
public void testGetArgs() {
List<String> args =
MysqlSyncDatabaseActionContext.builder()
.warehouse(WAREHOUSE)
.database(DATABASE)
.build()
.getArguments();
List<String> expectedArgs =
Arrays.asList(
"mysql_sync_database", "--warehouse", WAREHOUSE, "--database", DATABASE);
assertLinesMatch(expectedArgs, args);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/PostgresSyncTableActionContextTest.java | paimon-web-api/src/test/java/org/apache/paimon/web/api/action/context/PostgresSyncTableActionContextTest.java | /*
* 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.api.action.context;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertLinesMatch;
/**
* The test class of postgres sync table action context in {@link PostgresSyncTableActionContext}.
*/
public class PostgresSyncTableActionContextTest extends FlinkCdcActionContextTestBase {
@Test
public void testBuild() {
List<String> args =
PostgresSyncTableActionContext.builder()
.warehouse(WAREHOUSE)
.database(DATABASE)
.table(TABLE)
.build()
.getArguments();
List<String> expectedArgs =
Arrays.asList(
"postgres_sync_table",
"--warehouse",
WAREHOUSE,
"--database",
DATABASE,
"--table",
TABLE);
assertLinesMatch(expectedArgs, args);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/test/java/org/apache/paimon/web/api/shell/ShellServiceTest.java | paimon-web-api/src/test/java/org/apache/paimon/web/api/shell/ShellServiceTest.java | /*
* 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.api.shell;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/** The test class of shell execution in{@link ShellService}. */
public class ShellServiceTest {
@Test
public void testExecuteShell() throws IOException {
List<String> args = Arrays.asList("/bin/sh", "-c", "echo 1");
ShellService shellService = new ShellService("/", args);
Process execute = shellService.execute();
InputStream is = execute.getInputStream();
List<String> lines = IOUtils.readLines(is);
assertThat(lines.size() == 1 && "1".equals(lines.get(0))).isTrue();
}
@Test
public void testExecuteBash() throws IOException {
List<String> args = Arrays.asList("/bin/bash", "-c", "echo 1");
ShellService shellService = new ShellService("/", args);
Process execute = shellService.execute();
InputStream is = execute.getInputStream();
List<String> lines = IOUtils.readLines(is);
assertThat(lines.size() == 1 && "1".equals(lines.get(0))).isTrue();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/catalog/PaimonService.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/catalog/PaimonService.java | /*
* 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.api.catalog;
import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.schema.SchemaChange;
import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.table.Table;
import org.apache.paimon.types.DataType;
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.TableChange;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/** Paimon service. */
public class PaimonService {
private final Catalog catalog;
private final String name;
public PaimonService(Catalog catalog, String name) {
this.catalog = catalog;
this.name = name;
}
public Catalog catalog() {
return catalog;
}
public String catalogName() {
return name;
}
public List<String> listDatabases() {
return catalog.listDatabases();
}
public boolean databaseExists(String databaseName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
return catalog.databaseExists(databaseName);
}
public void createDatabase(String databaseName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
try {
catalog.createDatabase(databaseName, false);
} catch (Catalog.DatabaseAlreadyExistException e) {
throw new DatabaseException.DatabaseAlreadyExistsException(
String.format(
"The database '%s' already exists in the catalog.", databaseName));
}
}
public void createDatabase(String databaseName, boolean ignoreIfExists) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
try {
catalog.createDatabase(databaseName, ignoreIfExists);
} catch (Catalog.DatabaseAlreadyExistException e) {
throw new DatabaseException.DatabaseAlreadyExistsException(
String.format(
"The database '%s' already exists in the catalog.", databaseName));
}
}
public void dropDatabase(String databaseName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
try {
catalog.dropDatabase(databaseName, false, true);
} catch (Catalog.DatabaseNotExistException e) {
throw new DatabaseException.DatabaseNotExistException(
String.format(
"The database '%s' does not exist in the catalog.", databaseName));
} catch (Catalog.DatabaseNotEmptyException e) {
throw new DatabaseException.DatabaseNotEmptyException(
String.format("The database '%s' is not empty.", databaseName));
}
}
public void dropDatabase(String databaseName, boolean ignoreIfNotExists) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
try {
catalog.dropDatabase(databaseName, ignoreIfNotExists, true);
} catch (Catalog.DatabaseNotExistException e) {
throw new DatabaseException.DatabaseNotExistException(
String.format(
"The database '%s' does not exist in the catalog.", databaseName));
} catch (Catalog.DatabaseNotEmptyException e) {
throw new DatabaseException.DatabaseNotEmptyException(
String.format("The database '%s' is not empty.", databaseName));
}
}
public void dropDatabase(String databaseName, boolean ignoreIfNotExists, boolean cascade) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
try {
catalog.dropDatabase(databaseName, ignoreIfNotExists, cascade);
} catch (Catalog.DatabaseNotExistException e) {
throw new DatabaseException.DatabaseNotExistException(
String.format(
"The database '%s' does not exist in the catalog.", databaseName));
} catch (Catalog.DatabaseNotEmptyException e) {
throw new DatabaseException.DatabaseNotEmptyException(
String.format("The database '%s' is not empty.", databaseName));
}
}
public List<String> listTables(String databaseName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
try {
return catalog.listTables(databaseName);
} catch (Catalog.DatabaseNotExistException e) {
throw new DatabaseException.DatabaseNotExistException(
String.format(
"The database '%s' does not exist in the catalog.", databaseName));
}
}
public boolean tableExists(String databaseName, String tableName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
Preconditions.checkNotNull(tableName, "Table name cannot be null.");
Identifier identifier = Identifier.create(databaseName, tableName);
return catalog.tableExists(identifier);
}
public void createTable(String databaseName, String tableName, TableMetadata tableMetadata) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
Preconditions.checkNotNull(tableName, "Table name cannot be null.");
Schema.Builder schemaBuilder =
Schema.newBuilder()
.partitionKeys(
tableMetadata.partitionKeys() == null
? ImmutableList.of()
: ImmutableList.copyOf(tableMetadata.partitionKeys()))
.primaryKey(
tableMetadata.primaryKeys() == null
? ImmutableList.of()
: ImmutableList.copyOf(tableMetadata.primaryKeys()))
.comment(tableMetadata.comment() == null ? "" : tableMetadata.comment())
.options(tableMetadata.options());
for (ColumnMetadata column : tableMetadata.columns()) {
schemaBuilder.column(column.name(), column.type(), column.description());
}
Schema schema = schemaBuilder.build();
Identifier identifier = Identifier.create(databaseName, tableName);
try {
catalog.createTable(identifier, schema, false);
} catch (Catalog.TableAlreadyExistException e) {
throw new TableException.TableAlreadyExistException(
String.format("The table '%s' already exists in the database.", tableName));
} catch (Catalog.DatabaseNotExistException e) {
throw new DatabaseException.DatabaseNotExistException(
String.format(
"The database '%s' does not exist in the catalog.", databaseName));
}
}
public Table getTable(String databaseName, String tableName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
Preconditions.checkNotNull(tableName, "Table name cannot be null.");
Identifier identifier = Identifier.create(databaseName, tableName);
try {
return catalog.getTable(identifier);
} catch (Catalog.TableNotExistException e) {
throw new TableException.TableNotExistException(
String.format("The table '%s' does not exist in the database.", tableName));
}
}
public void dropTable(String databaseName, String tableName) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
Preconditions.checkNotNull(tableName, "Table name cannot be null.");
Identifier identifier = Identifier.create(databaseName, tableName);
try {
catalog.dropTable(identifier, false);
} catch (Catalog.TableNotExistException e) {
throw new TableException.TableNotExistException(
String.format("The table '%s' does not exist in the database.", tableName));
}
}
public void renameTable(String databaseName, String fromTable, String toTable) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
Preconditions.checkNotNull(fromTable, "From table name cannot be null.");
Preconditions.checkNotNull(toTable, "To table name cannot be null.");
Identifier fromTableIdentifier = Identifier.create(databaseName, fromTable);
Identifier toTableIdentifier = Identifier.create(databaseName, toTable);
try {
catalog.renameTable(fromTableIdentifier, toTableIdentifier, false);
} catch (Catalog.TableNotExistException e) {
throw new TableException.TableNotExistException(
String.format("The table '%s' does not exist in the database.", fromTable));
} catch (Catalog.TableAlreadyExistException e) {
throw new TableException.TableAlreadyExistException(
String.format("The table '%s' already exists in the database.", toTable));
}
}
public void alterTable(String databaseName, String tableName, List<TableChange> tableChanges) {
Preconditions.checkNotNull(databaseName, "Database name cannot be null.");
Preconditions.checkNotNull(tableName, "Table name cannot be null.");
if (!tableExists(databaseName, tableName)) {
return;
}
Identifier identifier = Identifier.create(databaseName, tableName);
List<SchemaChange> changes = new ArrayList<>();
if (null != tableChanges) {
List<SchemaChange> schemaChanges =
tableChanges.stream()
.flatMap(tableChange -> toSchemaChange(tableChange).stream())
.collect(Collectors.toList());
changes.addAll(schemaChanges);
}
try {
catalog.alterTable(identifier, changes, false);
} catch (Catalog.ColumnAlreadyExistException e) {
throw new ColumnException.ColumnAlreadyExistException(e.getMessage());
} catch (Catalog.TableNotExistException e) {
throw new TableException.TableNotExistException(
String.format("The table '%s' does not exist in the database.", tableName));
} catch (Catalog.ColumnNotExistException e) {
throw new ColumnException.ColumnNotExistException(e.getMessage());
}
}
private List<SchemaChange> toSchemaChange(TableChange change) {
List<SchemaChange> schemaChanges = new ArrayList<>();
if (change instanceof TableChange.AddColumn) {
TableChange.AddColumn add = (TableChange.AddColumn) change;
String comment = add.getColumn().description();
SchemaChange.Move move = getMove(add.getPosition(), add.getColumn().name());
schemaChanges.add(
SchemaChange.addColumn(
add.getColumn().name(), add.getColumn().type(), comment, move));
return schemaChanges;
} else if (change instanceof TableChange.DropColumn) {
TableChange.DropColumn drop = (TableChange.DropColumn) change;
schemaChanges.add(SchemaChange.dropColumn(drop.getColumnName()));
return schemaChanges;
} else if (change instanceof TableChange.ModifyColumnName) {
TableChange.ModifyColumnName modify = (TableChange.ModifyColumnName) change;
schemaChanges.add(
SchemaChange.renameColumn(
modify.getOldColumnName(), modify.getNewColumnName()));
return schemaChanges;
} else if (change instanceof TableChange.ModifyColumnType) {
TableChange.ModifyColumnType modify = (TableChange.ModifyColumnType) change;
DataType newColumnType = modify.getNewType();
DataType oldColumnType = modify.getOldColumn().type();
if (newColumnType.isNullable() != oldColumnType.isNullable()) {
schemaChanges.add(
SchemaChange.updateColumnNullability(
modify.getNewColumn().name(), newColumnType.isNullable()));
}
schemaChanges.add(
SchemaChange.updateColumnType(modify.getOldColumn().name(), newColumnType));
return schemaChanges;
} else if (change instanceof TableChange.ModifyColumnPosition) {
TableChange.ModifyColumnPosition modify = (TableChange.ModifyColumnPosition) change;
SchemaChange.Move move = getMove(modify.getNewPosition(), modify.getNewColumn().name());
schemaChanges.add(SchemaChange.updateColumnPosition(move));
return schemaChanges;
} else if (change instanceof TableChange.ModifyColumnComment) {
TableChange.ModifyColumnComment modify = (TableChange.ModifyColumnComment) change;
schemaChanges.add(
SchemaChange.updateColumnComment(
modify.getNewColumn().name(), modify.getNewComment()));
return schemaChanges;
} else if (change instanceof TableChange.SetOption) {
TableChange.SetOption setOption = (TableChange.SetOption) change;
String key = setOption.getKey();
String value = setOption.getValue();
SchemaManager.checkAlterTablePath(key);
schemaChanges.add(SchemaChange.setOption(key, value));
return schemaChanges;
} else if (change instanceof TableChange.RemoveOption) {
TableChange.RemoveOption removeOption = (TableChange.RemoveOption) change;
schemaChanges.add(SchemaChange.removeOption(removeOption.getKey()));
return schemaChanges;
} else {
throw new UnsupportedOperationException(
"Change is not supported: " + change.getClass());
}
}
private SchemaChange.Move getMove(TableChange.ColumnPosition columnPosition, String fieldName) {
SchemaChange.Move move = null;
if (columnPosition instanceof TableChange.First) {
move = SchemaChange.Move.first(fieldName);
} else if (columnPosition instanceof TableChange.After) {
move =
SchemaChange.Move.after(
fieldName, ((TableChange.After) columnPosition).column());
}
return move;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/catalog/PaimonServiceFactory.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/catalog/PaimonServiceFactory.java | /*
* 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.api.catalog;
import org.apache.paimon.catalog.CatalogContext;
import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.options.Options;
import org.apache.paimon.web.api.common.CatalogProperties;
import org.apache.paimon.web.api.common.MetastoreType;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
/** Paimon service factory. */
public class PaimonServiceFactory {
public static PaimonService createFileSystemCatalogService(
String name, String warehouse, Map<String, String> catalogOptions) {
if (catalogOptions == null) {
catalogOptions = new HashMap<>();
}
Options options = convertToPaimonOptions(catalogOptions);
CatalogContext context = CatalogContext.create(options);
options.set(CatalogProperties.WAREHOUSE, warehouse);
return new PaimonService(CatalogFactory.createCatalog(context), name);
}
public static Options convertToPaimonOptions(Map<String, String> catalogOptions) {
Options options = new Options();
String fileSystemType = catalogOptions.get("fileSystemType");
if ("s3".equalsIgnoreCase(fileSystemType)) {
options.set(CatalogProperties.S3_ENDPOINT, catalogOptions.get("endpoint"));
options.set(CatalogProperties.S3_ACCESS_KEY, catalogOptions.get("accessKey"));
options.set(CatalogProperties.S3_SECRET_KEY, catalogOptions.get("secretKey"));
} else if ("oss".equalsIgnoreCase(fileSystemType)) {
options.set(CatalogProperties.OSS_ENDPOINT, catalogOptions.get("endpoint"));
options.set(CatalogProperties.OSS_ACCESS_KEY_ID, catalogOptions.get("accessKey"));
options.set(CatalogProperties.OSS_ACCESS_KEY_SECRET, catalogOptions.get("secretKey"));
}
return options;
}
public static PaimonService createHiveCatalogService(
String name, String warehouse, String uri, String hiveConfDir) {
Options options = new Options();
options.set(CatalogProperties.WAREHOUSE, warehouse);
options.set(CatalogProperties.METASTORE, MetastoreType.HIVE.toString());
options.set(CatalogProperties.URI, uri);
if (StringUtils.isNotBlank(hiveConfDir)) {
options.set(CatalogProperties.HIVE_CONF_DIR, hiveConfDir);
}
CatalogContext context = CatalogContext.create(options);
return new PaimonService(CatalogFactory.createCatalog(context), name);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/service/ActionService.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/service/ActionService.java | /*
* 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.api.action.service;
import org.apache.paimon.web.api.action.context.ActionContext;
import org.apache.paimon.web.api.action.context.ActionExecutionResult;
/**
* Action service definition. Convert the user-configured CDC job into an ActionContext {@link
* ActionContext}, and then invoke the execute method to execute the action job.
*/
public interface ActionService {
ActionExecutionResult execute(ActionContext actionContext) throws Exception;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/service/FlinkCdcActionService.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/service/FlinkCdcActionService.java | /*
* 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.api.action.service;
import org.apache.paimon.web.api.action.context.ActionContext;
import org.apache.paimon.web.api.action.context.ActionExecutionResult;
import org.apache.paimon.web.api.action.context.FlinkActionContext;
import org.apache.paimon.web.api.enums.FlinkJobType;
import org.apache.paimon.web.api.exception.ActionException;
import org.apache.paimon.web.api.shell.ShellService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** An abstract Action service that executes actions through the shell. */
@Slf4j
public class FlinkCdcActionService implements ActionService {
private static final ExecutorService shellExecutor = Executors.newFixedThreadPool(5);
private List<String> getCommand(FlinkActionContext actionContext) {
List<String> commandList = new ArrayList<>();
commandList.add("bin/flink");
commandList.add("run");
if (actionContext.getFlinkJobType() != FlinkJobType.SESSION) {
throw new ActionException("Only support session job now.");
}
String sessionUrl = actionContext.getSessionUrl();
if (StringUtils.isNotBlank(sessionUrl)) {
commandList.add("-m");
commandList.add(sessionUrl);
}
commandList.add(actionContext.getJarPath());
commandList.addAll(actionContext.getArguments());
return commandList;
}
public ActionExecutionResult execute(ActionContext actionContext) throws Exception {
String flinkHome = getFlinkHome();
FlinkActionContext flinkActionContext;
if (!(actionContext instanceof FlinkActionContext)) {
throw new ActionException("Only support FlinkActionContext. ");
}
flinkActionContext = (FlinkActionContext) actionContext;
ActionExecutionResult result;
try {
List<String> command = getCommand(flinkActionContext);
Process process = new ShellService(flinkHome, command).execute();
shellExecutor.execute(
() -> {
try (InputStream inputStream = process.getInputStream();
InputStream errorStream = process.getErrorStream(); ) {
List<String> logLines =
IOUtils.readLines(inputStream, StandardCharsets.UTF_8);
for (String logLine : logLines) {
log.info(logLine);
}
List<String> errorLines =
IOUtils.readLines(errorStream, StandardCharsets.UTF_8);
for (String logLine : errorLines) {
log.error(logLine);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
result = ActionExecutionResult.success();
} catch (Exception exception) {
log.error(exception.getMessage(), exception);
result = ActionExecutionResult.fail(exception.getMessage());
}
return result;
}
private String getFlinkHome() {
String flinkHome = System.getenv("FLINK_HOME");
if (StringUtils.isBlank(flinkHome)) {
flinkHome = System.getProperty("FLINK_HOME");
}
if (StringUtils.isBlank(flinkHome)) {
throw new ActionException("FLINK_HOME is null");
}
return flinkHome;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/AbstractActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/AbstractActionContext.java | /*
* 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.api.action.context;
import org.apache.paimon.web.api.exception.ActionException;
import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* The AbstractActionContext provides a default implementation for getActionArgs. Its concrete
* subclasses only need to annotate the parameter fields of the action with the {@link ActionConf}
* annotation.
*/
@SuperBuilder
public abstract class AbstractActionContext implements ActionContext {
private String actionPath;
@Override
public List<String> getArguments() {
Class<?> clazz = this.getClass();
List<String> args = new ArrayList<>();
args.add(name());
addArgument(args, clazz, this);
return args;
}
private void addArgument(List<String> args, Class<?> clazz, Object obj) {
if (clazz == null || clazz == Object.class) {
return;
}
addArgument(args, clazz.getSuperclass(), obj);
Field[] declaredFields = clazz.getDeclaredFields();
for (Field declaredField : declaredFields) {
ActionConf actionConf = declaredField.getAnnotation(ActionConf.class);
if (actionConf == null) {
continue;
}
String confKey = actionConf.value();
Object confValue = null;
try {
declaredField.setAccessible(true);
confValue = declaredField.get(obj);
} catch (IllegalArgumentException | IllegalAccessException ignore) {
}
boolean nullable = declaredField.getAnnotation(Nullable.class) != null;
if (!nullable && confValue == null) {
throw new ActionException(confKey + " can not be null");
}
if (nullable && confValue == null) {
continue;
}
if (confValue instanceof List) {
ActionContextUtil.addConfList(args, confKey, (List<?>) confValue);
} else {
ActionContextUtil.addConf(args, confKey, String.valueOf(confValue));
}
}
}
public String getJarPath() {
return actionPath;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/FlinkCdcTableSyncActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/FlinkCdcTableSyncActionContext.java | /*
* 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.api.action.context;
import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import java.util.List;
/** The FlinkCdcTableSyncActionContext for the table synchronization. */
@SuperBuilder
public abstract class FlinkCdcTableSyncActionContext extends FlinkActionContext
implements ActionContext {
@ActionConf(value = "warehouse")
protected String warehouse;
@ActionConf(value = "database")
protected String database;
@ActionConf(value = "table")
protected String table;
@ActionConf("partition_keys")
@Nullable
protected String partitionKeys;
@ActionConf("primary_keys")
@Nullable
protected String primaryKeys;
@ActionConf("computed_column")
@Nullable
protected String computedColumn;
@ActionConf(value = "catalog_conf")
@Nullable
protected List<String> catalogConfList;
@ActionConf(value = "table_conf")
@Nullable
protected List<String> tableConfList;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionConf.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionConf.java | /*
* 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.api.action.context;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** ActionConf. */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ActionConf {
String value();
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionContextUtil.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionContextUtil.java | /*
* 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.api.action.context;
import org.apache.paimon.web.api.exception.ActionException;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** ActionContext Util. */
public class ActionContextUtil {
private ActionContextUtil() {}
public static void addConf(List<String> args, String confName, String conf) {
if (StringUtils.isNotBlank(conf)) {
args.add("--" + confName);
args.add(conf);
}
}
public static void addConfList(List<String> args, String confName, List<?> confList) {
if (confList != null && !confList.isEmpty()) {
for (Object conf : confList) {
addConf(args, confName, String.valueOf(conf));
}
}
}
public static String getActionJarPath() {
String actionJarPath = System.getenv("ACTION_JAR_PATH");
if (StringUtils.isBlank(actionJarPath)) {
actionJarPath = System.getProperty("ACTION_JAR_PATH");
}
if (StringUtils.isBlank(actionJarPath)) {
throw new ActionException("ACTION_JAR_PATH is null");
}
return actionJarPath;
}
public static List<String> getConfListFromString(String value, String spiltCharacter) {
if (StringUtils.isBlank(value)) {
return new ArrayList<>();
}
return Arrays.asList(value.split(spiltCharacter));
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/FlinkActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/FlinkActionContext.java | /*
* 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.api.action.context;
import org.apache.paimon.web.api.enums.FlinkJobType;
import lombok.experimental.SuperBuilder;
/** FlinkActionContext. */
@SuperBuilder
public abstract class FlinkActionContext extends AbstractActionContext implements ActionContext {
private String sessionUrl;
private FlinkJobType flinkJobType;
public String getSessionUrl() {
return sessionUrl;
}
public FlinkJobType getFlinkJobType() {
return flinkJobType;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/FlinkCdcDatabasesSyncActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/FlinkCdcDatabasesSyncActionContext.java | /*
* 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.api.action.context;
import org.apache.paimon.web.api.action.context.options.FlinkCdcOptions;
import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import java.util.List;
/** The FlinkCdcDatabasesActionContext for the entire database synchronization. */
@SuperBuilder
public abstract class FlinkCdcDatabasesSyncActionContext extends FlinkActionContext
implements ActionContext {
@ActionConf(value = FlinkCdcOptions.WAREHOUSE)
protected String warehouse;
@ActionConf(value = FlinkCdcOptions.DATABASE)
protected String database;
@ActionConf(value = FlinkCdcOptions.CATALOG_CONF)
@Nullable
protected List<String> catalogConfList;
@ActionConf(value = FlinkCdcOptions.TABLE_CONF)
@Nullable
protected List<String> tableConfList;
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/MysqlSyncTableActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/MysqlSyncTableActionContext.java | /*
* 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.api.action.context;
import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import java.util.List;
/** Mysql sync table action context. */
@SuperBuilder
public class MysqlSyncTableActionContext extends FlinkCdcTableSyncActionContext
implements ActionContext {
@ActionConf(value = "mysql_conf")
@Nullable
private final List<String> mysqlConfList;
@Override
public String name() {
return "mysql_sync_table";
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/PostgresSyncTableActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/PostgresSyncTableActionContext.java | /*
* 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.api.action.context;
import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import java.util.List;
/** Postgres sync table action context. */
@SuperBuilder
public class PostgresSyncTableActionContext extends FlinkCdcTableSyncActionContext {
@ActionConf(value = "postgres_conf")
@Nullable
private final List<String> postgresConfList;
public String name() {
return "postgres_sync_table";
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionContext.java | /*
* 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.api.action.context;
import java.util.List;
/** The context of action which converts the user-defined action to command line. */
public interface ActionContext {
String name();
/** Converts the user-defined action to command line. */
List<String> getArguments();
String getJarPath();
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionExecutionResult.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/ActionExecutionResult.java | /*
* 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.api.action.context;
/** ActionExecutionResult. */
public class ActionExecutionResult {
private boolean success;
private String errorMsg;
public static ActionExecutionResult success() {
ActionExecutionResult actionExecutionResult = new ActionExecutionResult();
actionExecutionResult.success = true;
return actionExecutionResult;
}
public static ActionExecutionResult fail(String errorMsg) {
ActionExecutionResult actionExecutionResult = new ActionExecutionResult();
actionExecutionResult.success = true;
actionExecutionResult.errorMsg = errorMsg;
return actionExecutionResult;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/MysqlSyncDatabaseActionContext.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/MysqlSyncDatabaseActionContext.java | /*
* 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.api.action.context;
import org.apache.paimon.web.api.action.context.options.FlinkCdcOptions;
import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import java.util.List;
/** Mysql sync database action context. */
@SuperBuilder
public class MysqlSyncDatabaseActionContext extends FlinkCdcDatabasesSyncActionContext
implements ActionContext {
@ActionConf(value = FlinkCdcOptions.MYSQL_CONF)
@Nullable
private final List<String> mysqlConfList;
public String name() {
return "mysql_sync_database";
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/options/FlinkCdcOptions.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/options/FlinkCdcOptions.java | /*
* 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.api.action.context.options;
/** FlinkCdcOptions. */
public class FlinkCdcOptions {
private FlinkCdcOptions() {}
public static final String MYSQL_CONF = "mysql_conf";
public static final String POSTGRES_CONF = "postgres_conf";
public static final String TABLE_CONF = "table_conf";
public static final String WAREHOUSE = "warehouse";
public static final String DATABASE = "database";
public static final String TABLE = "table";
public static final String PARTITION_KEYS = "partition_keys";
public static final String PRIMARY_KEYS = "primary_keys";
public static final String COMPUTED_COLUMN = "computed_column";
public static final String SESSION_URL = "sessionUrl";
public static final String CATALOG_CONF = "catalog_conf";
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/MysqlSyncDatabasesActionContextFactory.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/MysqlSyncDatabasesActionContextFactory.java | /*
* 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.api.action.context.factory;
import org.apache.paimon.web.api.action.context.ActionContext;
import org.apache.paimon.web.api.action.context.ActionContextUtil;
import org.apache.paimon.web.api.action.context.MysqlSyncDatabaseActionContext;
import org.apache.paimon.web.api.action.context.options.FlinkCdcOptions;
import org.apache.paimon.web.api.enums.FlinkCdcDataSourceType;
import org.apache.paimon.web.api.enums.FlinkCdcSyncType;
import org.apache.paimon.web.api.enums.FlinkJobType;
import org.apache.paimon.web.common.util.JSONUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
* A factory designed for creating {@link FlinkCdcActionContextFactory}, implementing full database
* synchronization with MySQL.
*/
public class MysqlSyncDatabasesActionContextFactory implements FlinkCdcActionContextFactory {
@Override
public String sourceType() {
return FlinkCdcDataSourceType.MYSQL.getType();
}
@Override
public String targetType() {
return FlinkCdcDataSourceType.PAIMON.getType();
}
@Override
public FlinkCdcSyncType cdcType() {
return FlinkCdcSyncType.ALL_DATABASES_SYNC;
}
@Override
public ActionContext getActionContext(ObjectNode actionConfigs) {
return MysqlSyncDatabaseActionContext.builder()
.sessionUrl(String.valueOf(actionConfigs.get(FlinkCdcOptions.SESSION_URL)))
.flinkJobType(FlinkJobType.SESSION)
.warehouse(JSONUtils.getString(actionConfigs, FlinkCdcOptions.WAREHOUSE))
.database(JSONUtils.getString(actionConfigs, FlinkCdcOptions.DATABASE))
.actionPath(ActionContextUtil.getActionJarPath())
.catalogConfList(JSONUtils.getList(actionConfigs, FlinkCdcOptions.CATALOG_CONF))
.mysqlConfList(JSONUtils.getList(actionConfigs, FlinkCdcOptions.MYSQL_CONF))
.build();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/ActionContextFactoryServiceLoadUtil.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/ActionContextFactoryServiceLoadUtil.java | /*
* 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.api.action.context.factory;
import org.apache.paimon.web.api.enums.FlinkCdcSyncType;
import org.apache.paimon.web.api.exception.ActionException;
import java.util.Objects;
import java.util.ServiceLoader;
/** ActionContextFactoryServiceLoadUtil. */
public class ActionContextFactoryServiceLoadUtil {
private ActionContextFactoryServiceLoadUtil() {}
public static FlinkCdcActionContextFactory getFlinkCdcActionContextFactory(
String sourceType, String targetType, FlinkCdcSyncType flinkCdcSyncType) {
ServiceLoader<FlinkCdcActionContextFactory> serviceLoader =
ServiceLoader.load(FlinkCdcActionContextFactory.class);
for (FlinkCdcActionContextFactory factory : serviceLoader) {
if (factory.cdcType() == flinkCdcSyncType
&& Objects.equals(factory.sourceType(), sourceType)
&& Objects.equals(factory.targetType(), targetType)) {
return factory;
}
}
throw new ActionException(("Could not find suitable FlinkCdcActionContextFactory."));
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/FlinkCdcActionContextFactory.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/FlinkCdcActionContextFactory.java | /*
* 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.api.action.context.factory;
import org.apache.paimon.web.api.enums.FlinkCdcSyncType;
/** FlinkCdcActionContextFactory. */
public interface FlinkCdcActionContextFactory extends ActionContextFactory {
String sourceType();
String targetType();
FlinkCdcSyncType cdcType();
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/MysqlSyncTableActionContextFactory.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/MysqlSyncTableActionContextFactory.java | /*
* 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.api.action.context.factory;
import org.apache.paimon.web.api.action.context.ActionContext;
import org.apache.paimon.web.api.action.context.ActionContextUtil;
import org.apache.paimon.web.api.action.context.MysqlSyncTableActionContext;
import org.apache.paimon.web.api.action.context.options.FlinkCdcOptions;
import org.apache.paimon.web.api.enums.FlinkCdcDataSourceType;
import org.apache.paimon.web.api.enums.FlinkCdcSyncType;
import org.apache.paimon.web.api.enums.FlinkJobType;
import org.apache.paimon.web.common.util.JSONUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
/** MysqlSyncTableActionContextFactory. */
public class MysqlSyncTableActionContextFactory implements FlinkCdcActionContextFactory {
@Override
public String sourceType() {
return FlinkCdcDataSourceType.MYSQL.getType();
}
@Override
public String targetType() {
return FlinkCdcDataSourceType.PAIMON.getType();
}
@Override
public FlinkCdcSyncType cdcType() {
return FlinkCdcSyncType.SINGLE_TABLE_SYNC;
}
@Override
public ActionContext getActionContext(ObjectNode actionConfigs) {
return MysqlSyncTableActionContext.builder()
.sessionUrl(String.valueOf(actionConfigs.get(FlinkCdcOptions.SESSION_URL)))
.flinkJobType(FlinkJobType.SESSION)
.warehouse(JSONUtils.getString(actionConfigs, FlinkCdcOptions.WAREHOUSE))
.database(JSONUtils.getString(actionConfigs, FlinkCdcOptions.DATABASE))
.table(JSONUtils.getString(actionConfigs, FlinkCdcOptions.TABLE))
.primaryKeys(JSONUtils.getString(actionConfigs, FlinkCdcOptions.PRIMARY_KEYS))
.actionPath(ActionContextUtil.getActionJarPath())
.catalogConfList(JSONUtils.getList(actionConfigs, FlinkCdcOptions.CATALOG_CONF))
.mysqlConfList(JSONUtils.getList(actionConfigs, FlinkCdcOptions.MYSQL_CONF))
.build();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/ActionContextFactory.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/ActionContextFactory.java | /*
* 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.api.action.context.factory;
import org.apache.paimon.web.api.action.context.ActionContext;
import com.fasterxml.jackson.databind.node.ObjectNode;
/** ActionContextFactory. */
public interface ActionContextFactory {
ActionContext getActionContext(ObjectNode actionConfigs);
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/PostgresSyncTableActionContextFactory.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/action/context/factory/PostgresSyncTableActionContextFactory.java | /*
* 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.api.action.context.factory;
import org.apache.paimon.web.api.action.context.ActionContext;
import org.apache.paimon.web.api.action.context.ActionContextUtil;
import org.apache.paimon.web.api.action.context.PostgresSyncTableActionContext;
import org.apache.paimon.web.api.action.context.options.FlinkCdcOptions;
import org.apache.paimon.web.api.enums.FlinkCdcDataSourceType;
import org.apache.paimon.web.api.enums.FlinkCdcSyncType;
import org.apache.paimon.web.api.enums.FlinkJobType;
import org.apache.paimon.web.common.util.JSONUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
/** PostgresSyncTableActionContextFactory. */
public class PostgresSyncTableActionContextFactory implements FlinkCdcActionContextFactory {
@Override
public String sourceType() {
return FlinkCdcDataSourceType.POSTGRESQL.getType();
}
@Override
public String targetType() {
return FlinkCdcDataSourceType.PAIMON.getType();
}
@Override
public FlinkCdcSyncType cdcType() {
return FlinkCdcSyncType.SINGLE_TABLE_SYNC;
}
@Override
public ActionContext getActionContext(ObjectNode actionConfigs) {
return PostgresSyncTableActionContext.builder()
.sessionUrl(String.valueOf(actionConfigs.get(FlinkCdcOptions.SESSION_URL)))
.flinkJobType(FlinkJobType.SESSION)
.warehouse(JSONUtils.getString(actionConfigs, FlinkCdcOptions.WAREHOUSE))
.database(JSONUtils.getString(actionConfigs, FlinkCdcOptions.DATABASE))
.table(JSONUtils.getString(actionConfigs, FlinkCdcOptions.TABLE))
.partitionKeys(JSONUtils.getString(actionConfigs, FlinkCdcOptions.PARTITION_KEYS))
.primaryKeys(JSONUtils.getString(actionConfigs, FlinkCdcOptions.PRIMARY_KEYS))
.computedColumn(JSONUtils.getString(actionConfigs, FlinkCdcOptions.COMPUTED_COLUMN))
.actionPath(ActionContextUtil.getActionJarPath())
.catalogConfList(JSONUtils.getList(actionConfigs, FlinkCdcOptions.CATALOG_CONF))
.postgresConfList(JSONUtils.getList(actionConfigs, FlinkCdcOptions.POSTGRES_CONF))
.build();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/DatabaseException.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/DatabaseException.java | /*
* 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.api.exception;
/** Database exception. */
public class DatabaseException extends RuntimeException {
public DatabaseException(String message) {
super(message);
}
/** The exception that the database already exists. */
public static class DatabaseAlreadyExistsException extends DatabaseException {
public DatabaseAlreadyExistsException(String message) {
super(message);
}
}
/** The exception that the database is not empty. */
public static class DatabaseNotEmptyException extends DatabaseException {
public DatabaseNotEmptyException(String message) {
super(message);
}
}
/** The exception that the database does not exist. */
public static class DatabaseNotExistException extends DatabaseException {
public DatabaseNotExistException(String message) {
super(message);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/ColumnException.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/ColumnException.java | /*
* 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.api.exception;
/** Column exception. */
public class ColumnException extends RuntimeException {
public ColumnException(String message) {
super(message);
}
/** The exception that the column has already existed. */
public static class ColumnAlreadyExistException extends ColumnException {
public ColumnAlreadyExistException(String message) {
super(message);
}
}
/** The exception that the column does not exist. */
public static class ColumnNotExistException extends ColumnException {
public ColumnNotExistException(String message) {
super(message);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/ActionException.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/ActionException.java | /*
* 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.api.exception;
/** Action exception. */
public class ActionException extends RuntimeException {
public ActionException() {}
public ActionException(String message) {
super(message);
}
public ActionException(String message, Throwable cause) {
super(message, cause);
}
public ActionException(Throwable cause) {
super(cause);
}
public ActionException(
String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/TableException.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/exception/TableException.java | /*
* 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.api.exception;
/** Table exception. */
public class TableException extends RuntimeException {
public TableException(String message) {
super(message);
}
/** The exception that the table already exists. */
public static class TableAlreadyExistException extends TableException {
public TableAlreadyExistException(String message) {
super(message);
}
}
/** The exception that the table does not exist. */
public static class TableNotExistException extends TableException {
public TableNotExistException(String message) {
super(message);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/common/CatalogProperties.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/common/CatalogProperties.java | /*
* 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.api.common;
/** paimon catalog properties. */
public class CatalogProperties {
public static final String METASTORE = "metastore";
public static final String WAREHOUSE = "warehouse";
public static final String URI = "uri";
public static final String S3_ENDPOINT = "s3.endpoint";
public static final String S3_SECRET_KEY = "s3.secret-key";
public static final String S3_ACCESS_KEY = "s3.access-key";
public static final String OSS_ENDPOINT = "fs.oss.endpoint";
public static final String OSS_ACCESS_KEY_ID = "fs.oss.accessKeyId";
public static final String OSS_ACCESS_KEY_SECRET = "fs.oss.accessKeySecret";
public static final String HIVE_CONF_DIR = "hive-conf-dir";
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/common/MetastoreType.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/common/MetastoreType.java | /*
* 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.api.common;
/** Enum of catalog metastore type. */
public enum MetastoreType {
FILE_SYSTEM("filesystem"),
HIVE("hive");
private final String value;
MetastoreType(String value) {
this.value = value;
}
public String toString() {
return value;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/shell/ShellService.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/shell/ShellService.java | /*
* 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.api.shell;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
import java.util.List;
/** Shell service. */
@Slf4j
public class ShellService {
private final String workingDirectory;
private final List<String> executeCommand;
public ShellService(String workingDirectory, List<String> executeCommand) {
this.workingDirectory = workingDirectory;
this.executeCommand = executeCommand;
}
public Process execute() throws IOException {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.directory(new File(workingDirectory));
processBuilder.redirectErrorStream(true);
processBuilder.command(executeCommand);
log.info("Executing shell command : {}", String.join(" ", executeCommand));
return processBuilder.start();
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/TableChange.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/TableChange.java | /*
* 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.api.table;
import org.apache.paimon.types.DataType;
import org.apache.paimon.web.api.table.metadata.ColumnMetadata;
import javax.annotation.Nullable;
import java.util.Objects;
/**
* This change represents the modification of the table including adding, modifying and dropping
* column etc.
*/
public interface TableChange {
static AddColumn add(ColumnMetadata column) {
return new AddColumn(column, null);
}
static AddColumn add(ColumnMetadata column, @Nullable ColumnPosition position) {
return new AddColumn(column, position);
}
static ModifyColumn modify(
ColumnMetadata oldColumn,
ColumnMetadata newColumn,
@Nullable ColumnPosition columnPosition) {
return new ModifyColumn(oldColumn, newColumn, columnPosition);
}
static ModifyColumnType modifyColumnType(ColumnMetadata oldColumn, DataType newType) {
return new ModifyColumnType(oldColumn, newType);
}
static ModifyColumnName modifyColumnName(ColumnMetadata oldColumn, String newName) {
return new ModifyColumnName(oldColumn, newName);
}
static ModifyColumnComment modifyColumnComment(ColumnMetadata oldColumn, String newComment) {
return new ModifyColumnComment(oldColumn, newComment);
}
static ModifyColumnPosition modifyColumnPosition(
ColumnMetadata oldColumn, ColumnPosition columnPosition) {
return new ModifyColumnPosition(oldColumn, columnPosition);
}
static DropColumn dropColumn(String columnName) {
return new DropColumn(columnName);
}
static SetOption set(String key, String value) {
return new SetOption(key, value);
}
static RemoveOption remove(String key) {
return new RemoveOption(key);
}
/** A table change to add a column. */
class AddColumn implements TableChange {
private final ColumnMetadata column;
private final ColumnPosition position;
private AddColumn(ColumnMetadata column, ColumnPosition position) {
this.column = column;
this.position = position;
}
public ColumnMetadata getColumn() {
return column;
}
@Nullable
public ColumnPosition getPosition() {
return position;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof AddColumn)) {
return false;
}
AddColumn addColumn = (AddColumn) o;
return Objects.equals(column, addColumn.column)
&& Objects.equals(position, addColumn.position);
}
@Override
public int hashCode() {
return Objects.hash(column, position);
}
@Override
public String toString() {
return "AddColumn{" + "column=" + column + ", position=" + position + '}';
}
}
/** A base schema change to modify a column. */
class ModifyColumn implements TableChange {
protected final ColumnMetadata oldColumn;
protected final ColumnMetadata newColumn;
protected final @Nullable ColumnPosition newPosition;
public ModifyColumn(
ColumnMetadata oldColumn,
ColumnMetadata newColumn,
@Nullable ColumnPosition newPosition) {
this.oldColumn = oldColumn;
this.newColumn = newColumn;
this.newPosition = newPosition;
}
public ColumnMetadata getOldColumn() {
return oldColumn;
}
public ColumnMetadata getNewColumn() {
return newColumn;
}
public @Nullable ColumnPosition getNewPosition() {
return newPosition;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ModifyColumn)) {
return false;
}
ModifyColumn that = (ModifyColumn) o;
return Objects.equals(oldColumn, that.oldColumn)
&& Objects.equals(newColumn, that.newColumn)
&& Objects.equals(newPosition, that.newPosition);
}
@Override
public int hashCode() {
return Objects.hash(oldColumn, newColumn, newPosition);
}
@Override
public String toString() {
return "ModifyColumn{"
+ "oldColumn="
+ oldColumn
+ ", newColumn="
+ newColumn
+ ", newPosition="
+ newPosition
+ '}';
}
}
/** A table change that modify the column data type. */
class ModifyColumnType extends ModifyColumn {
private ModifyColumnType(ColumnMetadata oldColumn, DataType newType) {
super(oldColumn, oldColumn.copy(newType), null);
}
/** Get the column type for the new column. */
public DataType getNewType() {
return newColumn.type();
}
@Override
public boolean equals(Object o) {
return (o instanceof ModifyColumnType) && super.equals(o);
}
@Override
public String toString() {
return "ModifyColumnType{" + "Column=" + oldColumn + ", newType=" + getNewType() + '}';
}
}
/** A table change to modify the column name. */
class ModifyColumnName extends ModifyColumn {
private ModifyColumnName(ColumnMetadata oldColumn, String newName) {
super(oldColumn, createNewColumn(oldColumn, newName), null);
}
private static ColumnMetadata createNewColumn(ColumnMetadata oldColumn, String newName) {
return new ColumnMetadata(newName, oldColumn.type(), oldColumn.description());
}
public String getOldColumnName() {
return oldColumn.name();
}
/** Returns the new column name after renaming the column name. */
public String getNewColumnName() {
return newColumn.name();
}
@Override
public boolean equals(Object o) {
return (o instanceof ModifyColumnName) && super.equals(o);
}
@Override
public String toString() {
return "ModifyColumnName{"
+ "Column="
+ oldColumn
+ ", newName="
+ getNewColumnName()
+ '}';
}
}
/** A table change to modify the column comment. */
class ModifyColumnComment extends ModifyColumn {
private final String newComment;
private ModifyColumnComment(ColumnMetadata oldColumn, String newComment) {
super(oldColumn, oldColumn.setComment(newComment), null);
this.newComment = newComment;
}
/** Get the new comment for the column. */
public String getNewComment() {
return newComment;
}
@Override
public boolean equals(Object o) {
return (o instanceof ModifyColumnComment) && super.equals(o);
}
@Override
public String toString() {
return "ModifyColumnComment{"
+ "Column="
+ oldColumn
+ ", newComment="
+ newComment
+ '}';
}
}
/** A table change to modify the column position. */
class ModifyColumnPosition extends ModifyColumn {
public ModifyColumnPosition(ColumnMetadata oldColumn, ColumnPosition newPosition) {
super(oldColumn, oldColumn, newPosition);
}
@Override
public boolean equals(Object o) {
return (o instanceof ModifyColumnPosition) && super.equals(o);
}
@Override
public String toString() {
return "ModifyColumnPosition{"
+ "Column="
+ oldColumn
+ ", newPosition="
+ newPosition
+ '}';
}
}
/** A table change to drop the column. */
class DropColumn implements TableChange {
private final String columnName;
private DropColumn(String columnName) {
this.columnName = columnName;
}
/** Returns the column name. */
public String getColumnName() {
return columnName;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DropColumn)) {
return false;
}
DropColumn that = (DropColumn) o;
return Objects.equals(columnName, that.columnName);
}
@Override
public int hashCode() {
return Objects.hash(columnName);
}
@Override
public String toString() {
return "DropColumn{" + "columnName=" + columnName + '}';
}
}
/** A table change to set the table option. */
class SetOption implements TableChange {
private final String key;
private final String value;
private SetOption(String key, String value) {
this.key = key;
this.value = value;
}
/** Returns the Option key to set. */
public String getKey() {
return key;
}
/** Returns the Option value to set. */
public String getValue() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SetOption)) {
return false;
}
SetOption setOption = (SetOption) o;
return Objects.equals(key, setOption.key) && Objects.equals(value, setOption.value);
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
@Override
public String toString() {
return "SetOption{" + "key=" + key + ", value=" + value + '}';
}
}
/** A table change to remove the table option. */
class RemoveOption implements TableChange {
private final String key;
public RemoveOption(String key) {
this.key = key;
}
/** Returns the Option key to reset. */
public String getKey() {
return key;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof RemoveOption)) {
return false;
}
RemoveOption that = (RemoveOption) o;
return Objects.equals(key, that.key);
}
@Override
public int hashCode() {
return Objects.hash(key);
}
@Override
public String toString() {
return "RemoveOption{" + "key=" + key + '}';
}
}
/** The position of the modified or added column. */
interface ColumnPosition {
/** Get the position to place the column at the first. */
static ColumnPosition first() {
return First.INSTANCE;
}
/** Get the position to place the column after the specified column. */
static ColumnPosition after(String column) {
return new After(column);
}
}
/** Column position FIRST means the specified column should be the first column. */
final class First implements ColumnPosition {
private static final First INSTANCE = new First();
private First() {}
@Override
public String toString() {
return "FIRST";
}
}
/** Column position AFTER means the specified column should be put after the given `column`. */
final class After implements ColumnPosition {
private final String column;
private After(String column) {
this.column = column;
}
public String column() {
return column;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof After)) {
return false;
}
After after = (After) o;
return Objects.equals(column, after.column);
}
@Override
public int hashCode() {
return Objects.hash(column);
}
@Override
public String toString() {
return String.format("AFTER %s", escapeIdentifier(column));
}
private static String escapeBackticks(String s) {
return s.replace("`", "``");
}
private static String escapeIdentifier(String s) {
return "`" + escapeBackticks(s) + "`";
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/ConsumerTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/ConsumerTableMetadata.java | /*
* 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.api.table.metadata;
/** file table metadata. */
public class ConsumerTableMetadata {
private String consumerId;
private Long nextSnapshotId;
public ConsumerTableMetadata(String consumerId, Long nextSnapshotId) {
this.consumerId = consumerId;
this.nextSnapshotId = nextSnapshotId;
}
public String getConsumerId() {
return consumerId;
}
public void setConsumerId(String consumerId) {
this.consumerId = consumerId;
}
public Long getNextSnapshotId() {
return nextSnapshotId;
}
public void setNextSnapshotId(Long nextSnapshotId) {
this.nextSnapshotId = nextSnapshotId;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/TagTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/TagTableMetadata.java | /*
* 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.api.table.metadata;
import javax.annotation.Nullable;
import java.time.LocalDateTime;
/** file table metadata. */
public class TagTableMetadata {
private final String tagName;
private final Long snapshotId;
private final Long schemaId;
private final LocalDateTime createTime;
private final Long recordCount;
public TagTableMetadata(
String tagName,
Long snapshotId,
Long schemaId,
LocalDateTime createTime,
Long recordCount) {
this.tagName = tagName;
this.snapshotId = snapshotId;
this.schemaId = schemaId;
this.createTime = createTime;
this.recordCount = recordCount;
}
public String getTagName() {
return tagName;
}
public Long getSnapshotId() {
return snapshotId;
}
public Long getSchemaId() {
return schemaId;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public Long getRecordCount() {
return recordCount;
}
public static TagTableMetadata.Builder builder() {
return new Builder();
}
/** The builder for TagTableMetadata. */
public static final class Builder {
private String tagName;
private Long snapshotId;
private Long schemaId;
private LocalDateTime createTime;
@Nullable private Long recordCount;
public Builder tagName(String tagName) {
this.tagName = tagName;
return this;
}
public Builder snapshotId(Long snapshotId) {
this.snapshotId = snapshotId;
return this;
}
public Builder schemaId(Long schemaId) {
this.schemaId = schemaId;
return this;
}
public Builder createTime(LocalDateTime createTime) {
this.createTime = createTime;
return this;
}
public Builder recordCount(Long recordCount) {
this.recordCount = recordCount;
return this;
}
public TagTableMetadata build() {
return new TagTableMetadata(tagName, snapshotId, schemaId, createTime, recordCount);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/SchemaTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/SchemaTableMetadata.java | /*
* 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.api.table.metadata;
import javax.annotation.Nullable;
/** schema table metadata. */
public class SchemaTableMetadata {
private final Long schemaId;
private final String fields;
private final String partitionKeys;
private final String primaryKeys;
private final String options;
private final String comment;
public SchemaTableMetadata(
Long schemaId,
String fields,
String partitionKeys,
String primaryKeys,
String options,
String comment) {
this.schemaId = schemaId;
this.fields = fields;
this.partitionKeys = partitionKeys;
this.primaryKeys = primaryKeys;
this.options = options;
this.comment = comment;
}
public Long getSchemaId() {
return schemaId;
}
public String getFields() {
return fields;
}
public String getPartitionKeys() {
return partitionKeys;
}
public String getPrimaryKeys() {
return primaryKeys;
}
public String getOptions() {
return options;
}
public String getComment() {
return comment;
}
public static SchemaTableMetadata.Builder builder() {
return new Builder();
}
/** The builder for SchemaTableMetadata. */
public static final class Builder {
private Long schemaId;
private String fields;
private String partitionKeys;
private String primaryKeys;
private String options;
@Nullable private String comment;
public Builder schemaId(Long schemaId) {
this.schemaId = schemaId;
return this;
}
public Builder fields(String fields) {
this.fields = fields;
return this;
}
public Builder partitionKeys(String partitionKeys) {
this.partitionKeys = partitionKeys;
return this;
}
public Builder primaryKeys(String primaryKeys) {
this.primaryKeys = primaryKeys;
return this;
}
public Builder options(String options) {
this.options = options;
return this;
}
public Builder comment(String comment) {
this.comment = comment;
return this;
}
public SchemaTableMetadata build() {
return new SchemaTableMetadata(
schemaId, fields, partitionKeys, primaryKeys, options, comment);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/FileTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/FileTableMetadata.java | /*
* 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.api.table.metadata;
import javax.annotation.Nullable;
import java.time.LocalDateTime;
/** file table metadata. */
public class FileTableMetadata {
private final String partition;
private final Integer bucket;
private final String filePath;
private final String fileFormat;
private final Long schemaId;
private final Integer level;
private final Long recordCount;
private final Long fileSizeInBytes;
private final String minKey;
private final String maxKey;
private final String nullValueCounts;
private final String minValueStats;
private final String maxValueStats;
private final LocalDateTime creationTime;
public FileTableMetadata(
String partition,
Integer bucket,
String filePath,
String fileFormat,
Long schemaId,
Integer level,
Long recordCount,
Long fileSizeInBytes,
String minKey,
String maxKey,
String nullValueCounts,
String minValueStats,
String maxValueStats,
LocalDateTime creationTime) {
this.partition = partition;
this.bucket = bucket;
this.filePath = filePath;
this.fileFormat = fileFormat;
this.schemaId = schemaId;
this.level = level;
this.recordCount = recordCount;
this.fileSizeInBytes = fileSizeInBytes;
this.minKey = minKey;
this.maxKey = maxKey;
this.nullValueCounts = nullValueCounts;
this.minValueStats = minValueStats;
this.maxValueStats = maxValueStats;
this.creationTime = creationTime;
}
public String getPartition() {
return partition;
}
public Integer getBucket() {
return bucket;
}
public String getFilePath() {
return filePath;
}
public String getFileFormat() {
return fileFormat;
}
public Long getSchemaId() {
return schemaId;
}
public Integer getLevel() {
return level;
}
public Long getRecordCount() {
return recordCount;
}
public Long getFileSizeInBytes() {
return fileSizeInBytes;
}
public String getMinKey() {
return minKey;
}
public String getMaxKey() {
return maxKey;
}
public String getNullValueCounts() {
return nullValueCounts;
}
public String getMinValueStats() {
return minValueStats;
}
public String getMaxValueStats() {
return maxValueStats;
}
public LocalDateTime getCreationTime() {
return creationTime;
}
public static FileTableMetadata.Builder builder() {
return new Builder();
}
/** The builder for FileTableMetadata. */
public static final class Builder {
@Nullable private String partition;
private Integer bucket;
private String filePath;
private String fileFormat;
private Long schemaId;
private Integer level;
private Long recordCount;
private Long fileSizeInBytes;
private String minKey;
private String maxKey;
private String nullValueCounts;
@Nullable private String minValueStats;
@Nullable private String maxValueStats;
private LocalDateTime creationTime;
public Builder partition(String partition) {
this.partition = partition;
return this;
}
public Builder bucket(Integer bucket) {
this.bucket = bucket;
return this;
}
public Builder filePath(String filePath) {
this.filePath = filePath;
return this;
}
public Builder fileFormat(String fileFormat) {
this.fileFormat = fileFormat;
return this;
}
public Builder schemaId(Long schemaId) {
this.schemaId = schemaId;
return this;
}
public Builder level(Integer level) {
this.level = level;
return this;
}
public Builder recordCount(Long recordCount) {
this.recordCount = recordCount;
return this;
}
public Builder fileSizeInBytes(Long fileSizeInBytes) {
this.fileSizeInBytes = fileSizeInBytes;
return this;
}
public Builder minKey(String minKey) {
this.minKey = minKey;
return this;
}
public Builder maxKey(String maxKey) {
this.maxKey = maxKey;
return this;
}
public Builder nullValueCounts(String nullValueCounts) {
this.nullValueCounts = nullValueCounts;
return this;
}
public Builder minValueStats(String minValueStats) {
this.minValueStats = minValueStats;
return this;
}
public Builder maxValueStats(String maxValueStats) {
this.maxValueStats = maxValueStats;
return this;
}
public Builder creationTime(LocalDateTime creationTime) {
this.creationTime = creationTime;
return this;
}
public FileTableMetadata build() {
return new FileTableMetadata(
partition,
bucket,
filePath,
fileFormat,
schemaId,
level,
recordCount,
fileSizeInBytes,
minKey,
maxKey,
nullValueCounts,
minValueStats,
maxValueStats,
creationTime);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/ColumnMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/ColumnMetadata.java | /*
* 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.api.table.metadata;
import org.apache.paimon.types.DataType;
import javax.annotation.Nullable;
/** table metadata. */
public class ColumnMetadata {
private final String name;
private final DataType type;
private final @Nullable String description;
public ColumnMetadata(String name) {
this(name, null, null);
}
public ColumnMetadata(String name, DataType type) {
this(name, type, null);
}
public ColumnMetadata(String name, DataType type, String description) {
this.name = name;
this.type = type;
this.description = description;
}
public String name() {
return this.name;
}
public DataType type() {
return this.type;
}
public String description() {
return this.description;
}
public ColumnMetadata copy(DataType newDataType) {
return new ColumnMetadata(this.name, newDataType, this.description);
}
public ColumnMetadata setComment(String comment) {
return comment == null ? this : new ColumnMetadata(this.name, this.type, comment);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/OptionTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/OptionTableMetadata.java | /*
* 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.api.table.metadata;
/** options table metadata. */
public class OptionTableMetadata {
private String key;
private String value;
public OptionTableMetadata(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/ManifestTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/ManifestTableMetadata.java | /*
* 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.api.table.metadata;
/** manifest table metadata. */
public class ManifestTableMetadata {
private final String fileName;
private final Long fileSize;
private final Long numAddedFiles;
private final Long numDeletedFiles;
private final Long schemaId;
public ManifestTableMetadata(
String fileName,
Long fileSize,
Long numAddedFiles,
Long numDeletedFiles,
Long schemaId) {
this.fileName = fileName;
this.fileSize = fileSize;
this.numAddedFiles = numAddedFiles;
this.numDeletedFiles = numDeletedFiles;
this.schemaId = schemaId;
}
public String getFileName() {
return fileName;
}
public Long getFileSize() {
return fileSize;
}
public Long getNumAddedFiles() {
return numAddedFiles;
}
public Long getNumDeletedFiles() {
return numDeletedFiles;
}
public Long getSchemaId() {
return schemaId;
}
public static ManifestTableMetadata.Builder builder() {
return new Builder();
}
/** The builder for ManifestTableMetadata. */
public static final class Builder {
private String fileName;
private Long fileSize;
private Long numAddedFiles;
private Long numDeletedFiles;
private Long schemaId;
public Builder fileName(String fileName) {
this.fileName = fileName;
return this;
}
public Builder fileSize(Long fileSize) {
this.fileSize = fileSize;
return this;
}
public Builder numAddedFiles(Long numAddedFiles) {
this.numAddedFiles = numAddedFiles;
return this;
}
public Builder numDeletedFiles(Long numDeletedFiles) {
this.numDeletedFiles = numDeletedFiles;
return this;
}
public Builder schemaId(Long schemaId) {
this.schemaId = schemaId;
return this;
}
public ManifestTableMetadata build() {
return new ManifestTableMetadata(
fileName, fileSize, numAddedFiles, numDeletedFiles, schemaId);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/TableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/TableMetadata.java | /*
* 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.api.table.metadata;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/** table metadata. */
public class TableMetadata {
private final List<ColumnMetadata> columns;
private final List<String> partitionKeys;
private final List<String> primaryKeys;
private final Map<String, String> options;
private final String comment;
public TableMetadata(
List<ColumnMetadata> columns,
List<String> partitionKeys,
List<String> primaryKeys,
Map<String, String> options,
String comment) {
this.columns = normalizeFields(columns, primaryKeys, partitionKeys);
this.partitionKeys = partitionKeys;
this.primaryKeys = primaryKeys;
this.options = new HashMap<>(options);
this.comment = comment;
}
public List<ColumnMetadata> columns() {
return columns;
}
public List<String> partitionKeys() {
return partitionKeys;
}
public List<String> primaryKeys() {
return primaryKeys;
}
public Map<String, String> options() {
return options;
}
public String comment() {
return comment;
}
private static List<ColumnMetadata> normalizeFields(
List<ColumnMetadata> columns, List<String> primaryKeys, List<String> partitionKeys) {
List<String> fieldNames =
columns.stream().map(ColumnMetadata::name).collect(Collectors.toList());
Set<String> duplicateColumns = duplicate(fieldNames);
Preconditions.checkState(
duplicateColumns.isEmpty(),
"Table column %s must not contain duplicate fields. Found: %s",
fieldNames,
duplicateColumns);
Set<String> allFields = new HashSet<>(fieldNames);
duplicateColumns = duplicate(partitionKeys);
Preconditions.checkState(
duplicateColumns.isEmpty(),
"Partition key constraint %s must not contain duplicate columns. Found: %s",
partitionKeys,
duplicateColumns);
Preconditions.checkState(
allFields.containsAll(partitionKeys),
"Table column %s should include all partition fields %s",
fieldNames,
partitionKeys);
if (primaryKeys.isEmpty()) {
return columns;
}
duplicateColumns = duplicate(primaryKeys);
Preconditions.checkState(
duplicateColumns.isEmpty(),
"Primary key constraint %s must not contain duplicate columns. Found: %s",
primaryKeys,
duplicateColumns);
Preconditions.checkState(
allFields.containsAll(primaryKeys),
"Table column %s should include all primary key constraint %s",
fieldNames,
primaryKeys);
Set<String> pkSet = new HashSet<>(primaryKeys);
Preconditions.checkState(
pkSet.containsAll(partitionKeys),
"Primary key constraint %s should include all partition fields %s",
primaryKeys,
partitionKeys);
// primary key should not nullable
List<ColumnMetadata> newFields = new ArrayList<>();
for (ColumnMetadata field : columns) {
if (pkSet.contains(field.name()) && field.type().isNullable()) {
newFields.add(
new ColumnMetadata(
field.name(), field.type().copy(false), field.description()));
} else {
newFields.add(field);
}
}
return newFields;
}
private static Set<String> duplicate(List<String> names) {
return names.stream()
.filter(name -> Collections.frequency(names, name) > 1)
.collect(Collectors.toSet());
}
@Override
public String toString() {
return "TableMetadata{"
+ "columns="
+ columns
+ ", partitionKeys="
+ partitionKeys
+ ", primaryKeys="
+ primaryKeys
+ ", options="
+ options
+ ", comment='"
+ comment
+ '\''
+ '}';
}
public static TableMetadata.Builder builder() {
return new Builder();
}
/** The builder for TableMetadata. */
public static final class Builder {
private List<ColumnMetadata> columns = new ArrayList<>();
private List<String> partitionKeys = new ArrayList<>();
private List<String> primaryKeys = new ArrayList<>();
@Nullable private Map<String, String> options = new HashMap<>();
@Nullable private String comment;
public Builder columns(List<ColumnMetadata> columns) {
this.columns = new ArrayList<>(columns);
return this;
}
public Builder partitionKeys(List<String> partitionKeys) {
this.partitionKeys = new ArrayList<>(partitionKeys);
return this;
}
public Builder primaryKeys(List<String> primaryKeys) {
this.primaryKeys = new ArrayList<>(primaryKeys);
return this;
}
public Builder options(Map<String, String> options) {
this.options.putAll(options);
return this;
}
public Builder comment(String comment) {
this.comment = comment;
return this;
}
public TableMetadata build() {
return new TableMetadata(columns, partitionKeys, primaryKeys, options, comment);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/SnapshotTableMetadata.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/table/metadata/SnapshotTableMetadata.java | /*
* 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.api.table.metadata;
import javax.annotation.Nullable;
import java.time.LocalDateTime;
/** snapshot table metadata. */
public class SnapshotTableMetadata {
private final Long snapshotId;
private final String snapshotPath;
private final Long schemaId;
private final String commitUser;
private final Long commitIdentifier;
private final String commitKind;
private final LocalDateTime commitTime;
private final Long totalRecordCount;
private final Long deltaRecordCount;
private final Long changelogRecordCount;
private final Long watermark;
public SnapshotTableMetadata(
Long snapshotId,
String snapshotPath,
Long schemaId,
String commitUser,
Long commitIdentifier,
String commitKind,
LocalDateTime commitTime,
Long totalRecordCount,
Long deltaRecordCount,
Long changelogRecordCount,
Long watermark) {
this.snapshotId = snapshotId;
this.snapshotPath = snapshotPath;
this.schemaId = schemaId;
this.commitUser = commitUser;
this.commitIdentifier = commitIdentifier;
this.commitKind = commitKind;
this.commitTime = commitTime;
this.totalRecordCount = totalRecordCount;
this.deltaRecordCount = deltaRecordCount;
this.changelogRecordCount = changelogRecordCount;
this.watermark = watermark;
}
public Long getSnapshotId() {
return snapshotId;
}
public String getSnapshotPath() {
return snapshotPath;
}
public Long getSchemaId() {
return schemaId;
}
public String getCommitUser() {
return commitUser;
}
public Long getCommitIdentifier() {
return commitIdentifier;
}
public String getCommitKind() {
return commitKind;
}
public LocalDateTime getCommitTime() {
return commitTime;
}
public Long getTotalRecordCount() {
return totalRecordCount;
}
public Long getDeltaRecordCount() {
return deltaRecordCount;
}
public Long getChangelogRecordCount() {
return changelogRecordCount;
}
public Long getWatermark() {
return watermark;
}
public static SnapshotTableMetadata.Builder builder() {
return new Builder();
}
/** The builder for SnapshotTableMetadata. */
public static final class Builder {
private Long snapshotId;
private String snapshotPath;
private Long schemaId;
private String commitUser;
private Long commitIdentifier;
private String commitKind;
private LocalDateTime commitTime;
@Nullable private Long totalRecordCount;
@Nullable private Long deltaRecordCount;
@Nullable private Long changelogRecordCount;
@Nullable private Long watermark;
public Builder snapshotId(Long snapshotId) {
this.snapshotId = snapshotId;
return this;
}
public Builder snapshotPath(String snapshotPath) {
this.snapshotPath = snapshotPath;
return this;
}
public Builder schemaId(Long schemaId) {
this.schemaId = schemaId;
return this;
}
public Builder commitUser(String commitUser) {
this.commitUser = commitUser;
return this;
}
public Builder commitIdentifier(Long commitIdentifier) {
this.commitIdentifier = commitIdentifier;
return this;
}
public Builder commitKind(String commitKind) {
this.commitKind = commitKind;
return this;
}
public Builder commitTime(LocalDateTime commitTime) {
this.commitTime = commitTime;
return this;
}
public Builder totalRecordCount(Long totalRecordCount) {
this.totalRecordCount = totalRecordCount;
return this;
}
public Builder deltaRecordCount(Long deltaRecordCount) {
this.deltaRecordCount = deltaRecordCount;
return this;
}
public Builder changelogRecordCount(Long changelogRecordCount) {
this.changelogRecordCount = changelogRecordCount;
return this;
}
public Builder watermark(Long watermark) {
this.watermark = watermark;
return this;
}
public SnapshotTableMetadata build() {
return new SnapshotTableMetadata(
snapshotId,
snapshotPath,
schemaId,
commitUser,
commitIdentifier,
commitKind,
commitTime,
totalRecordCount,
deltaRecordCount,
changelogRecordCount,
watermark);
}
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkCdcSyncType.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkCdcSyncType.java | /*
* 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.api.enums;
import lombok.Getter;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** FlinkCdcType. */
@Getter
public enum FlinkCdcSyncType {
SINGLE_TABLE_SYNC(0),
ALL_DATABASES_SYNC(1);
private final Integer value;
private static final Map<Integer, FlinkCdcSyncType> enumsMap;
static {
enumsMap =
Arrays.stream(FlinkCdcSyncType.values())
.collect(Collectors.toMap(FlinkCdcSyncType::getValue, Function.identity()));
}
FlinkCdcSyncType(Integer value) {
this.value = value;
}
public static FlinkCdcSyncType valueOf(Integer value) {
if (enumsMap.containsKey(value)) {
return enumsMap.get(value);
}
throw new RuntimeException("Invalid cdc sync type.");
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkCdcDataSourceType.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkCdcDataSourceType.java | /*
* 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.api.enums;
import lombok.Getter;
import java.util.Arrays;
import java.util.Objects;
/** FlinkCdcDataSourceType. */
@Getter
public enum FlinkCdcDataSourceType {
MYSQL("MySQL"),
PAIMON("Paimon"),
POSTGRESQL("PostgreSQL");
private final String type;
FlinkCdcDataSourceType(String type) {
this.type = type;
}
public static FlinkCdcDataSourceType of(String type) {
return Arrays.stream(values())
.filter(x -> Objects.equals(x.getType(), type))
.findFirst()
.orElse(null);
}
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
apache/paimon-webui | https://github.com/apache/paimon-webui/blob/ef0db0b0189c2aa4f47056543fdb063120868ec2/paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkJobType.java | paimon-web-api/src/main/java/org/apache/paimon/web/api/enums/FlinkJobType.java | /*
* 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.api.enums;
/** FlinkJobType. */
public enum FlinkJobType {
SESSION,
PER_JOB,
APPLICATION
}
| java | Apache-2.0 | ef0db0b0189c2aa4f47056543fdb063120868ec2 | 2026-01-05T02:42:23.250368Z | false |
liveservices/LiveSDK-for-Android | https://github.com/liveservices/LiveSDK-for-Android/blob/7feda438a5492a7544fdad527325b5b05f760cc5/src/src/com/microsoft/live/LiveAuthListener.java | src/src/com/microsoft/live/LiveAuthListener.java | // ------------------------------------------------------------------------------
// Copyright (c) 2014 Microsoft Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ------------------------------------------------------------------------------
package com.microsoft.live;
/**
* Handles callback methods for LiveAuthClient init, login, and logout methods.
* Returns the * status of the operation when onAuthComplete is called. If there was an error
* during the operation, onAuthError is called with the exception that was thrown.
*/
public interface LiveAuthListener {
/**
* Invoked when the operation completes successfully.
*
* @param status The {@link LiveStatus} for an operation. If successful, the status is
* CONNECTED. If unsuccessful, NOT_CONNECTED or UNKNOWN are returned.
* @param session The {@link LiveConnectSession} from the {@link LiveAuthClient}.
* @param userState An arbitrary object that is used to determine the caller of the method.
*/
public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState);
/**
* Invoked when the method call fails.
*
* @param exception The {@link LiveAuthException} error.
* @param userState An arbitrary object that is used to determine the caller of the method.
*/
public void onAuthError(LiveAuthException exception, Object userState);
}
| java | MIT | 7feda438a5492a7544fdad527325b5b05f760cc5 | 2026-01-05T02:42:35.605851Z | false |
liveservices/LiveSDK-for-Android | https://github.com/liveservices/LiveSDK-for-Android/blob/7feda438a5492a7544fdad527325b5b05f760cc5/src/src/com/microsoft/live/LiveDownloadOperationListener.java | src/src/com/microsoft/live/LiveDownloadOperationListener.java | // ------------------------------------------------------------------------------
// Copyright (c) 2014 Microsoft Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ------------------------------------------------------------------------------
package com.microsoft.live;
/**
* Represents any functionality related to downloads that works with the Live Connect
* Representational State Transfer (REST) API.
*/
public interface LiveDownloadOperationListener {
/**
* Called when the associated download operation call completes.
* @param operation The {@link LiveDownloadOperation} object.
*/
public void onDownloadCompleted(LiveDownloadOperation operation);
/**
* Called when the associated download operation call fails.
* @param exception The error returned by the REST operation call.
* @param operation The {@link LiveDownloadOperation} object.
*/
public void onDownloadFailed(LiveOperationException exception,
LiveDownloadOperation operation);
/**
* Updates the progression of the download.
* @param totalBytes The total bytes downloaded.
* @param bytesRemaining The bytes remaining to download.
* @param operation The {@link LiveDownloadOperation} object.
*/
public void onDownloadProgress(int totalBytes,
int bytesRemaining,
LiveDownloadOperation operation);
}
| java | MIT | 7feda438a5492a7544fdad527325b5b05f760cc5 | 2026-01-05T02:42:35.605851Z | false |
liveservices/LiveSDK-for-Android | https://github.com/liveservices/LiveSDK-for-Android/blob/7feda438a5492a7544fdad527325b5b05f760cc5/src/src/com/microsoft/live/OverwriteOption.java | src/src/com/microsoft/live/OverwriteOption.java | // ------------------------------------------------------------------------------
// Copyright (c) 2014 Microsoft Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ------------------------------------------------------------------------------
package com.microsoft.live;
/**
* Enum that specifies what to do during a naming conflict during an upload.
*/
public enum OverwriteOption {
/** Overwrite the existing file. */
Overwrite {
@Override
protected String overwriteQueryParamValue() {
return "true";
}
},
/** Do Not Overwrite the existing file and cancel the upload. */
DoNotOverwrite {
@Override
protected String overwriteQueryParamValue() {
return "false";
}
},
/** Rename the current file to avoid a name conflict. */
Rename {
@Override
protected String overwriteQueryParamValue() {
return "choosenewname";
}
};
/**
* Leaves any existing overwrite query parameter on appends this overwrite
* to the given UriBuilder.
*/
void appendQueryParameterOnTo(UriBuilder uri) {
uri.appendQueryParameter(QueryParameters.OVERWRITE, this.overwriteQueryParamValue());
}
abstract protected String overwriteQueryParamValue();
}
| java | MIT | 7feda438a5492a7544fdad527325b5b05f760cc5 | 2026-01-05T02:42:35.605851Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.