or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

catalog.mdconfiguration.mddata-source.mdfunctions.mdindex.mdtable-api.md

catalog.mddocs/

0

# Catalog Management

1

2

Complete Hive metastore integration for metadata operations including database, table, partition, and function management. HiveCatalog provides seamless access to existing Hive table definitions and schemas.

3

4

## Capabilities

5

6

### HiveCatalog

7

8

Main catalog implementation that integrates with Hive metastore for comprehensive metadata management.

9

10

```java { .api }

11

/**

12

* Hive catalog implementation for metadata operations with Hive metastore

13

*/

14

public class HiveCatalog extends AbstractCatalog {

15

/**

16

* Create HiveCatalog with basic configuration

17

* @param catalogName - Name of the catalog

18

* @param defaultDatabase - Default database name

19

* @param hiveConfDir - Path to Hive configuration directory

20

*/

21

public HiveCatalog(String catalogName, String defaultDatabase, String hiveConfDir);

22

23

/**

24

* Create HiveCatalog with specific Hive version

25

* @param catalogName - Name of the catalog

26

* @param defaultDatabase - Default database name

27

* @param hiveConfDir - Path to Hive configuration directory

28

* @param hiveVersion - Hive version specification

29

*/

30

public HiveCatalog(String catalogName, String defaultDatabase, String hiveConfDir, String hiveVersion);

31

32

/**

33

* Create HiveCatalog with Hadoop configuration

34

* @param catalogName - Name of the catalog

35

* @param defaultDatabase - Default database name

36

* @param hiveConfDir - Path to Hive configuration directory

37

* @param hadoopConfDir - Path to Hadoop configuration directory

38

* @param hiveVersion - Hive version specification

39

*/

40

public HiveCatalog(String catalogName, String defaultDatabase, String hiveConfDir, String hadoopConfDir, String hiveVersion);

41

42

/**

43

* Create HiveCatalog with pre-configured HiveConf

44

* @param catalogName - Name of the catalog

45

* @param defaultDatabase - Default database name

46

* @param hiveConf - Pre-configured Hive configuration object

47

* @param hiveVersion - Hive version specification

48

*/

49

public HiveCatalog(String catalogName, String defaultDatabase, HiveConf hiveConf, String hiveVersion);

50

51

/** Open catalog connection */

52

public void open() throws CatalogException;

53

54

/** Close catalog connection */

55

public void close() throws CatalogException;

56

57

/** Get Hive configuration object */

58

public HiveConf getHiveConf();

59

}

60

```

61

62

**Usage Examples:**

63

64

```java

65

import org.apache.flink.table.catalog.hive.HiveCatalog;

66

import org.apache.flink.table.api.TableEnvironment;

67

import org.apache.hadoop.hive.conf.HiveConf;

68

69

// Basic catalog setup

70

HiveCatalog catalog = new HiveCatalog("myhive", "default", "/opt/hive/conf");

71

72

// With specific Hive version

73

HiveCatalog catalog = new HiveCatalog("myhive", "default", "/opt/hive/conf", "3.1.2");

74

75

// With Hadoop configuration

76

HiveCatalog catalog = new HiveCatalog(

77

"myhive",

78

"default",

79

"/opt/hive/conf",

80

"/opt/hadoop/conf",

81

"3.1.2"

82

);

83

84

// Register catalog with table environment

85

TableEnvironment tableEnv = TableEnvironment.create(settings);

86

tableEnv.registerCatalog("myhive", catalog);

87

tableEnv.useCatalog("myhive");

88

```

89

90

### Database Operations

91

92

Manage Hive databases through the catalog interface.

93

94

```java { .api }

95

/** Create a new database */

96

public void createDatabase(String databaseName, CatalogDatabase database, boolean ignoreIfExists)

97

throws DatabaseAlreadyExistException, CatalogException;

98

99

/** Drop an existing database */

100

public void dropDatabase(String databaseName, boolean ignoreIfNotExists, boolean cascade)

101

throws DatabaseNotExistException, DatabaseNotEmptyException, CatalogException;

102

103

/** List all databases */

104

public List<String> listDatabases() throws CatalogException;

105

106

/** Check if database exists */

107

public boolean databaseExists(String databaseName) throws CatalogException;

108

109

/** Get database metadata */

110

public CatalogDatabase getDatabase(String databaseName)

111

throws DatabaseNotExistException, CatalogException;

112

```

113

114

### Table Operations

115

116

Comprehensive table metadata management including creation, modification, and discovery.

117

118

```java { .api }

119

/** Create a new table */

120

public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ignoreIfExists)

121

throws TableAlreadyExistException, DatabaseNotExistException, CatalogException;

122

123

/** Alter an existing table */

124

public void alterTable(ObjectPath tablePath, CatalogBaseTable newTable, boolean ignoreIfNotExists)

125

throws TableNotExistException, CatalogException;

126

127

/** Drop an existing table */

128

public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)

129

throws TableNotExistException, CatalogException;

130

131

/** List all tables in a database */

132

public List<String> listTables(String databaseName)

133

throws DatabaseNotExistException, CatalogException;

134

135

/** Check if table exists */

136

public boolean tableExists(ObjectPath tablePath) throws CatalogException;

137

138

/** Get table metadata */

139

public CatalogBaseTable getTable(ObjectPath tablePath)

140

throws TableNotExistException, CatalogException;

141

```

142

143

### Partition Operations

144

145

Manage Hive table partitions for optimized data access.

146

147

```java { .api }

148

/** Create a new partition */

149

public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec,

150

CatalogPartition partition, boolean ignoreIfExists)

151

throws TableNotExistException, PartitionAlreadyExistsException, CatalogException;

152

153

/** Drop an existing partition */

154

public void dropPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, boolean ignoreIfNotExists)

155

throws PartitionNotExistException, CatalogException;

156

157

/** List all partitions for a table */

158

public List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath)

159

throws TableNotExistException, TableNotPartitionedException, CatalogException;

160

161

/** List partitions matching specification */

162

public List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)

163

throws TableNotExistException, TableNotPartitionedException, CatalogException;

164

165

/** Check if partition exists */

166

public boolean partitionExists(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)

167

throws CatalogException;

168

169

/** Get partition metadata */

170

public CatalogPartition getPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)

171

throws PartitionNotExistException, CatalogException;

172

```

173

174

### Function Operations

175

176

Manage Hive user-defined functions through the catalog.

177

178

```java { .api }

179

/** Create a new function */

180

public void createFunction(ObjectPath functionPath, CatalogFunction function, boolean ignoreIfExists)

181

throws FunctionAlreadyExistException, DatabaseNotExistException, CatalogException;

182

183

/** Alter an existing function */

184

public void alterFunction(ObjectPath functionPath, CatalogFunction newFunction, boolean ignoreIfNotExists)

185

throws FunctionNotExistException, CatalogException;

186

187

/** Drop an existing function */

188

public void dropFunction(ObjectPath functionPath, boolean ignoreIfNotExists)

189

throws FunctionNotExistException, CatalogException;

190

191

/** List all functions in a database */

192

public List<String> listFunctions(String databaseName)

193

throws DatabaseNotExistException, CatalogException;

194

195

/** Check if function exists */

196

public boolean functionExists(ObjectPath functionPath) throws CatalogException;

197

198

/** Get function metadata */

199

public CatalogFunction getFunction(ObjectPath functionPath)

200

throws FunctionNotExistException, CatalogException;

201

```

202

203

### Catalog Factory

204

205

Factory for creating HiveCatalog instances from configuration properties.

206

207

```java { .api }

208

public class HiveCatalogFactory implements CatalogFactory {

209

/** Create catalog from configuration */

210

public Catalog createCatalog(String name, Map<String, String> properties);

211

212

/** Get factory identifier */

213

public String factoryIdentifier();

214

215

/** Get required configuration options */

216

public Set<ConfigOption<?>> requiredOptions();

217

218

/** Get optional configuration options */

219

public Set<ConfigOption<?>> optionalOptions();

220

}

221

```

222

223

### Statistics Management

224

225

Table and partition statistics management for query optimization and planning.

226

227

```java { .api }

228

/** Get table statistics */

229

public CatalogTableStatistics getTableStatistics(ObjectPath tablePath)

230

throws TableNotExistException, CatalogException;

231

232

/** Get table column statistics */

233

public CatalogColumnStatistics getTableColumnStatistics(ObjectPath tablePath)

234

throws TableNotExistException, CatalogException;

235

236

/** Update table statistics */

237

public void alterTableStatistics(ObjectPath tablePath, CatalogTableStatistics tableStatistics, boolean ignoreIfNotExists)

238

throws TableNotExistException, CatalogException;

239

240

/** Update table column statistics */

241

public void alterTableColumnStatistics(ObjectPath tablePath, CatalogColumnStatistics columnStatistics, boolean ignoreIfNotExists)

242

throws TableNotExistException, CatalogException, TablePartitionedException;

243

244

/** Get partition statistics */

245

public CatalogTableStatistics getPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)

246

throws PartitionNotExistException, CatalogException;

247

248

/** Get partition column statistics */

249

public CatalogColumnStatistics getPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)

250

throws PartitionNotExistException, CatalogException;

251

252

/** Update partition statistics */

253

public void alterPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogTableStatistics partitionStatistics, boolean ignoreIfNotExists)

254

throws PartitionNotExistException, CatalogException;

255

256

/** Update partition column statistics */

257

public void alterPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogColumnStatistics columnStatistics, boolean ignoreIfNotExists)

258

throws PartitionNotExistException, CatalogException;

259

```

260

261

### Configuration Options

262

263

Configuration constants for HiveCatalog factory and behavior.

264

265

```java { .api }

266

public class HiveCatalogFactoryOptions {

267

/** Factory identifier constant */

268

public static final String IDENTIFIER = "hive";

269

270

/** Default database configuration option */

271

public static final ConfigOption<String> DEFAULT_DATABASE;

272

273

/** Hive configuration directory option */

274

public static final ConfigOption<String> HIVE_CONF_DIR;

275

276

/** Hive version specification option */

277

public static final ConfigOption<String> HIVE_VERSION;

278

279

/** Hadoop configuration directory option */

280

public static final ConfigOption<String> HADOOP_CONF_DIR;

281

}

282

283

public class HiveCatalogConfig {

284

/** Comment metadata key */

285

public static final String COMMENT = "comment";

286

287

/** Column types separator */

288

public static final String DEFAULT_LIST_COLUMN_TYPES_SEPARATOR = ":";

289

290

/** Partition location metadata key */

291

public static final String PARTITION_LOCATION = "partition.location";

292

}

293

```