Skip to content

[Transform] finish backport: adapt versions to 7.11 #65961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public SettingsConfig(Integer maxPageSearchSize, Float docsPerSecond, Integer da
public SettingsConfig(final StreamInput in) throws IOException {
this.maxPageSearchSize = in.readOptionalInt();
this.docsPerSecond = in.readOptionalFloat();
if (in.getVersion().onOrAfter(Version.V_8_0_0)) { // todo: change to V_7_11
if (in.getVersion().onOrAfter(Version.V_7_11_0)) {
this.datesAsEpochMillis = in.readOptionalInt();
} else {
this.datesAsEpochMillis = DEFAULT_DATES_AS_EPOCH_MILLIS;
Expand Down Expand Up @@ -115,7 +115,7 @@ public boolean isValid() {
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalInt(maxPageSearchSize);
out.writeOptionalFloat(docsPerSecond);
if (out.getVersion().onOrAfter(Version.V_8_0_0)) { // todo: change to V_7_11_0
if (out.getVersion().onOrAfter(Version.V_7_11_0)) {
out.writeOptionalInt(datesAsEpochMillis);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public static TransformConfig rewriteForUpdate(final TransformConfig transformCo
// quick check if a rewrite is required, if none found just return the original
// a failing quick check, does not mean a rewrite is necessary
if (transformConfig.getVersion() != null
&& transformConfig.getVersion().onOrAfter(Version.V_8_0_0) // todo: V_7_11_0
&& transformConfig.getVersion().onOrAfter(Version.V_7_11_0)
&& (transformConfig.getPivotConfig() == null || transformConfig.getPivotConfig().getMaxPageSearchSize() == null)) {
return transformConfig;
}
Expand Down Expand Up @@ -491,7 +491,7 @@ private static TransformConfig applyRewriteForUpdate(Builder builder) {
}

// 2. set dates_as_epoch_millis to true for transforms < 7.11 to keep BWC
if (builder.getVersion() != null && builder.getVersion().before(Version.V_8_0_0)) { // todo: V_7_11_0
if (builder.getVersion() != null && builder.getVersion().before(Version.V_7_11_0)) {
builder.setSettings(
new SettingsConfig(builder.getSettings().getMaxPageSearchSize(), builder.getSettings().getDocsPerSecond(), true)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ public void testRewriteForBWCOfDateNormalization() throws IOException {

TransformConfig explicitTrueAfter711 = new TransformConfig.Builder(transformConfig).setSettings(
new SettingsConfig.Builder(transformConfigRewritten.getSettings()).setDatesAsEpochMillis(true).build()
).setVersion(Version.V_8_0_0).build(); // todo: V_7_11_0
).setVersion(Version.V_7_11_0).build();

transformConfigRewritten = TransformConfig.rewriteForUpdate(explicitTrueAfter711);

assertTrue(transformConfigRewritten.getSettings().getDatesAsEpochMillis());
assertEquals(Version.V_8_0_0, transformConfigRewritten.getVersion()); // todo: V_7_11_0
assertEquals(Version.V_7_11_0, transformConfigRewritten.getVersion());
}

private TransformConfig createTransformConfigFromString(String json, String id) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public Stream<Map<String, Object>> extractResults(
// >= 7.11 as string
// note: it depends on the version when the transform has been created, not the version of the code
boolean datesAsEpoch = settings.getDatesAsEpochMillis() != null ? settings.getDatesAsEpochMillis()
: version.onOrAfter(Version.V_8_0_0) ? false // todo V_7_11_0
: version.onOrAfter(Version.V_7_11_0) ? false
: true;

return AggregationResultUtils.extractCompositeAggregationResults(
Expand Down