Skip to content

Commit

Permalink
Merge pull request #1261 from atlanhq/APP-5055
Browse files Browse the repository at this point in the history
Replace importers with xformers
  • Loading branch information
cmgrote authored Jan 28, 2025
2 parents 7c47d93 + df6b689 commit df991f9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 620 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ package com.atlan.pkg.rab

import RelationalAssetsBuilderCfg
import com.atlan.model.assets.Asset
import com.atlan.model.assets.Column
import com.atlan.model.assets.Connection
import com.atlan.model.assets.ISQL
import com.atlan.model.enums.AssetCreationHandling
import com.atlan.model.enums.AtlanConnectorType
import com.atlan.pkg.PackageContext
import com.atlan.pkg.serde.RowDeserializer
import com.atlan.pkg.serde.csv.CSVImporter
import com.atlan.pkg.serde.csv.ImportResults
import mu.KLogger
import java.util.stream.Stream

Expand All @@ -28,22 +32,38 @@ class ConnectionImporter(
ctx: PackageContext<RelationalAssetsBuilderCfg>,
private val inputFile: String,
logger: KLogger,
) : AssetImporter(
) : CSVImporter(
ctx = ctx,
delta = null,
filename = inputFile,
// Only allow full or updates to connections, as partial connections would be hidden
// and impossible to delete via utilities like the Connection Delete workflow
typeNameFilter = Connection.TYPE_NAME,
logger = logger,
typeNameFilter = Connection.TYPE_NAME,
attrsToOverwrite = attributesToClear(ctx.config.assetsAttrToOverwrite.toMutableList(), "assets", logger),
creationHandling = if (ctx.config.assetsUpsertSemantic == "update") AssetCreationHandling.NONE else AssetCreationHandling.FULL,
batchSize = 1,
trackBatches = true,
fieldSeparator = ctx.config.assetsFieldSeparator[0],
failOnErrors = ctx.config.assetsFailOnErrors,
) {
companion object {
const val CONNECTOR_TYPE = "connectorType"
}

/** {@inheritDoc} */
override fun import(columnsToSkip: Set<String>): ImportResults? {
// Can skip all of these columns when deserializing a row as they will be set by
// the creator methods anyway
return super.import(
setOf(
Asset.CONNECTION_NAME.atlanFieldName,
ISQL.DATABASE_NAME.atlanFieldName,
ISQL.SCHEMA_NAME.atlanFieldName,
AssetXformer.ENTITY_NAME,
ColumnXformer.COLUMN_PARENT_QN,
Column.ORDER.atlanFieldName,
),
)
}

/** {@inheritDoc} */
@Suppress("UNCHECKED_CAST")
override fun getBuilder(deserializer: RowDeserializer): Asset.AssetBuilder<*, *> {
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit df991f9

Please sign in to comment.