Skip to content

Commit

Permalink
fix: add backward compatible APIs for get columns (#441)
Browse files Browse the repository at this point in the history
* add backward compatible methods for get column

* remove @ sign

* nit

---------

Co-authored-by: Yang Yang <[email protected]>
  • Loading branch information
jphui and Yang Yang authored Oct 2, 2024
1 parent 80c8b23 commit abfb659
Showing 1 changed file with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ public static String getAspectColumnName(@Nonnull final String entityType, @Nonn
return ASPECT_PREFIX + getColumnName(entityType, aspectCanonicalName);
}

/**
* DEPRECATED, use getAspectColumnName(String entityType, String aspectCanonicalName) instead.
*/
@Deprecated
@Nonnull
public static String getAspectColumnName(@Nonnull final String aspectCanonicalName) {
return ASPECT_PREFIX + getColumnNameFromAnnotation(aspectCanonicalName);
}

/**
* Get column name from aspect class.
* @param aspectClass aspect class
Expand Down Expand Up @@ -158,6 +167,20 @@ public static String getGeneratedColumnName(@Nonnull String assetType, @Nonnull
return INDEX_PREFIX + getColumnName(assetType, aspect) + processPath(path, delimiter);
}

/**
* DEPRECATED, use getGeneratedColumnName(assetType, aspect, path, nonDollarVirtualColumnsEnabled) instead.
*/
@Deprecated
@Nonnull
public static String getGeneratedColumnName(@Nonnull String aspect, @Nonnull String path,
boolean nonDollarVirtualColumnsEnabled) {
char delimiter = nonDollarVirtualColumnsEnabled ? '0' : '$';
if (isUrn(aspect)) {
return INDEX_PREFIX + "urn" + processPath(path, delimiter);
}
return INDEX_PREFIX + getColumnNameFromAnnotation(aspect) + processPath(path, delimiter);
}

/**
* Check the given class name is for urn class.
*/
Expand Down Expand Up @@ -193,7 +216,9 @@ public static String getColumnName(@Nonnull final String assetType,

Class<? extends RecordTemplate> assetClass = GlobalAssetRegistry.get(assetType);
if (assetClass == null) {
return getColumnNameFromAnnotation(assetType, aspectCanonicalName);
log.warn("loading column name from legacy 'column' annotation. asset: {}, aspect: {}", assetType,
aspectCanonicalName);
return getColumnNameFromAnnotation(aspectCanonicalName);
} else {
String aspectAlias = ModelUtils.getAspectAlias(assetClass, aspectCanonicalName);
if (aspectAlias == null) {
Expand All @@ -208,15 +233,11 @@ public static String getColumnName(@Nonnull final String assetType,
/**
* Get Column name from aspect column annotation (legacy).
*
* @param assetType entity type from Urn definition.
* @param aspectCanonicalName aspect name in canonical form.
* @return aspect column name
*/
@Nonnull
private static String getColumnNameFromAnnotation(@Nonnull final String assetType,
@Nonnull final String aspectCanonicalName) {
log.warn("loading column name from legacy 'column' annotation. asset: {}, aspect: {}", assetType,
aspectCanonicalName);
private static String getColumnNameFromAnnotation(@Nonnull final String aspectCanonicalName) {
// load column from Aspect annotation (legacy way)
try {
final RecordDataSchema schema =
Expand Down

0 comments on commit abfb659

Please sign in to comment.