Skip to content

Commit

Permalink
Merge pull request #1323 from atlanhq/APP-5462
Browse files Browse the repository at this point in the history
Adds generic SourceTag and SnowflakeTag handling
  • Loading branch information
cmgrote authored Feb 13, 2025
2 parents ae8f0dc + 71bcfd3 commit 62e054e
Show file tree
Hide file tree
Showing 582 changed files with 8,141 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AssetImportCfg
import com.atlan.exception.NotFoundException
import com.atlan.model.assets.Asset
import com.atlan.model.assets.SnowflakeTag
import com.atlan.model.enums.AtlanConnectorType
import com.atlan.model.assets.SourceTag
import com.atlan.model.enums.AtlanEnum
import com.atlan.model.enums.AtlanIcon
import com.atlan.model.enums.AtlanTagColor
Expand All @@ -26,7 +26,6 @@ import de.siegmar.fastcsv.reader.CsvRecord
import mu.KLogger
import java.io.IOException
import java.nio.file.Paths
import java.util.concurrent.ThreadLocalRandom
import java.util.concurrent.atomic.AtomicLong
import kotlin.streams.asSequence

Expand Down Expand Up @@ -104,6 +103,7 @@ class AtlanTagImporter(
row.getOrElse(TAG_ICON) { "" },
row.getOrElse(TAG_CONNECTION) { "" },
row.getOrElse(TAG_CONNECTOR) { "" }.lowercase(),
row.getOrElse(TAG_SRC_ID) { "" },
CellXformer.parseDelimitedList(row.getOrElse(ALLOWED_VALUES) { "" }),
)

Expand Down Expand Up @@ -181,8 +181,34 @@ class AtlanTagImporter(
}

private fun idempotentTagAsset(tag: TagDetails): Asset? {
// TODO: replace with creator() call, and generic SourceTag — should be idempotent already (?)
return if (tag.sourceSynced) {
val assetBuilder =
when (tag.connectorType) {
"snowflake" -> {
// TODO: actually use a schema for Snowflake, not just a connection
SnowflakeTag.creator(
tag.name,
tag.connectionQualifiedName,
tag.name,
tag.tagIdInSource,
tag.allowedValues,
)
}
else -> {
SourceTag.creator(
tag.name,
tag.connectionQualifiedName,
tag.name,
tag.tagIdInSource,
tag.allowedValues,
)
}
}
assetBuilder.build()
} else {
null
}
/*return if (tag.sourceSynced) {
// Source tag asset
val assetBuilder =
SnowflakeTag
Expand All @@ -200,7 +226,7 @@ class AtlanTagImporter(
assetBuilder.build()
} else {
null
}
}*/
}

companion object {
Expand All @@ -209,17 +235,8 @@ class AtlanTagImporter(
const val TAG_ICON = "Icon"
const val TAG_CONNECTION = "Synced connection name"
const val TAG_CONNECTOR = "Synced connector type"
const val TAG_SRC_ID = "Tag ID in source"
const val ALLOWED_VALUES = "Allowed values for tag"
val HEADER =
listOf(
TAG_NAME,
TAG_COLOR,
TAG_ICON,
TAG_CONNECTION,
TAG_CONNECTOR,
ALLOWED_VALUES,
)
const val NO_CONNECTION_QN = "NO_CONNECTION_FOUND"

fun getTagName(
row: List<String>,
Expand Down Expand Up @@ -251,6 +268,7 @@ class AtlanTagImporter(
val icon: String,
val connectionName: String,
val connectorType: String,
val tagIdInSource: String,
val allowedValues: List<String>,
) {
val connectionQualifiedName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TagManagementTest : PackageTest("tm") {
override val logger = Utils.getLogger(this.javaClass.name)

private val c1 = makeUnique("c1")
private val c1Type = AtlanConnectorType.SNOWFLAKE // TODO: swap to BigID once generic SourceTag is in place
private val c1Type = AtlanConnectorType.BIGID
private val t1 = makeUnique("t1")
private val t2 = makeUnique("t2")

Expand Down
6 changes: 3 additions & 3 deletions samples/packages/asset-import/src/test/resources/tags.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Atlan tag name,Color,Icon,Synced connection name,Synced connector type,Allowed values for tag
Atlan tag name,Color,Icon,Synced connection name,Synced connector type,Allowed values for tag,Tag ID in source
{{TAG1}},Green,PhRecycle,{{CONNECTION}},{{CTYPE}},"X
Y
Z"
{{TAG2}},,https://assets.atlan.com/assets/announcement-issue-png.png,,,
Z",42
{{TAG2}},,https://assets.atlan.com/assets/announcement-issue-png.png,,,,
3 changes: 2 additions & 1 deletion sdk/src/main/java/com/atlan/generators/GeneratorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public class GeneratorConfig {
Map.entry("exceptionsForBusinessPolicy", "exceptionForBusinessPolicy"),
Map.entry("supersetChartFormData", "putSupersetChartFormData"),
Map.entry("columnHierarchy", "putColumnHierarchy"),
Map.entry("bigqueryTagHierarchy", "putBigqueryTagHierarchy"));
Map.entry("bigqueryTagHierarchy", "putBigqueryTagHierarchy"),
Map.entry("applications", "aiApplication"));

private static final Map<String, String> DEFAULT_ATTRIBUTE_RENAMES = Map.ofEntries(
Map.entry("connectorName", "connectorType"),
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/main/java/com/atlan/model/assets/ADLSAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public class ADLSAccount extends Asset
@Attribute
ADLSStorageKind adlsAccountKind;

/** Name of the account for this ADLS asset. */
@Attribute
String adlsAccountName;

/** Performance of this account. */
@Attribute
ADLSPerformance adlsAccountPerformance;
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/main/java/com/atlan/model/assets/ADLSContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class ADLSContainer extends Asset
@Attribute
IADLSAccount adlsAccount;

/** Name of the account for this ADLS asset. */
@Attribute
String adlsAccountName;

/** Unique name of the account for this ADLS asset. */
@Attribute
String adlsAccountQualifiedName;
Expand Down
8 changes: 8 additions & 0 deletions sdk/src/main/java/com/atlan/model/assets/ADLSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class ADLSObject extends Asset
@Builder.Default
String typeName = TYPE_NAME;

/** Name of the account for this ADLS asset. */
@Attribute
String adlsAccountName;

/** Unique name of the account for this ADLS asset. */
@Attribute
String adlsAccountQualifiedName;
Expand All @@ -68,6 +72,10 @@ public class ADLSObject extends Asset
@Attribute
IADLSContainer adlsContainer;

/** Name of the container this object exists within. */
@Attribute
String adlsContainerName;

/** Unique name of the container this object exists within. */
@Attribute
String adlsContainerQualifiedName;
Expand Down
Loading

0 comments on commit 62e054e

Please sign in to comment.