Skip to content
Open
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
26 changes: 26 additions & 0 deletions fe/fe-catalog/src/main/java/org/apache/doris/analysis/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Legacy Expr persistence — Review Guide

Legacy `Expr` objects are persisted by metadata consumers such as Routine Load images and
`ALTER ROUTINE LOAD` journals. Doris Gson serializes only fields annotated with
`@SerializedName`, so an unclassified field can be silently lost during FE recovery.

## Expr changes

- [ ] Any field that changes `ExprToSqlVisitor` output has a stable `@SerializedName` key.
- [ ] Existing serialized keys are not renamed, removed, or reused for a different meaning.
- [ ] Analysis caches and execution-only fields remain unpersisted only when they can be rebuilt
after the restored expression is converted to SQL and analyzed again.
- [ ] Every unpersisted instance field is listed with that rationale in
`ExprGsonSerializationTest.NON_DURABLE_EXPR_FIELDS`; do not add fields to the list merely to
make the test pass.
- [ ] New concrete `Expr` subtypes are registered in both Gson factories and have a non-default
sample in `ExprGsonSerializationTest`.
- [ ] Samples set every SQL-relevant option to a non-default value so semantic loss is observable.

## Required tests

- [ ] `ExprGsonSerializationTest` preserves the concrete subtype and `ExprToSqlVisitor` output
with and without table names across Gson round-trip.
- [ ] Metadata consumers that introduce a new Expr carrier add an image and journal replay test.
- [ ] Routine Load expression changes cover column mappings, preceding filters, where filters, and
delete conditions as applicable.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class FunctionCallExpr extends Expr {

private FunctionParams aggFnParams;

@SerializedName("obe")
private List<OrderByElement> orderByElements = Lists.newArrayList();

// check analytic function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public String getName() {
private String invertedIndexParserStopwords = "";
private String invertedIndexAnalyzerName = "";
// Fields for SQL generation
@SerializedName("ea")
private String explicitAnalyzer = "";

private MatchPredicate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
package org.apache.doris.analysis;

import com.google.common.collect.Lists;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
* Combination of expr and ASC/DESC, and nulls ordering.
*/
public class OrderByElement {
@SerializedName("e")
private Expr expr;
@SerializedName("ia")
private final boolean isAsc;

// Represents the NULLs ordering specified: true when "NULLS FIRST", false when
// "NULLS LAST", and null if not specified.
@SerializedName("nfp")
private final Boolean nullsFirstParam;

public OrderByElement(Expr expr, boolean isAsc, Boolean nullsFirstParam) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
import org.apache.doris.catalog.Type;

import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;

import java.nio.ByteBuffer;

// PlaceHolderExpr is a reference class point to real LiteralExpr
public class PlaceHolderExpr extends LiteralExpr {
@SerializedName("le")
private LiteralExpr lExpr;
@SerializedName("mtc")
int mysqlTypeCode = -1;

public PlaceHolderExpr() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.doris.catalog.Index;
import org.apache.doris.catalog.Type;

import com.google.gson.annotations.SerializedName;

import java.util.Collections;
import java.util.List;

Expand All @@ -29,6 +31,7 @@
* for BE VSearchExpr processing. This is only used during FE->BE translation.
*/
public class SearchPredicate extends Predicate {
@SerializedName("dsl")
private final String dslString;
private final QsPlan qsPlan;
private final List<Index> fieldIndexes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class SlotRef extends Expr {
@SerializedName("col")
private String col;
// Used in toSql
@SerializedName("l")
private String label;
@SerializedName("scp")
private List<String> subColPath;

// results of analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.Type;

import com.google.gson.annotations.SerializedName;

public class TimeV2Literal extends LiteralExpr {
public static final TimeV2Literal MIN_VALUE = new TimeV2Literal(838, 59, 59, 999999, 6, true);
public static final TimeV2Literal MAX_VALUE = new TimeV2Literal(838, 59, 59, 999999, 6, false);

@SerializedName("h")
protected int hour;
@SerializedName("m")
protected int minute;
@SerializedName("s")
protected int second;
@SerializedName("us")
protected int microsecond;
@SerializedName("neg")
protected boolean negative;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@

package org.apache.doris.analysis;

import com.google.gson.annotations.SerializedName;

import java.math.BigDecimal;
import java.util.Objects;

// Variable expr: including the system variable and user define variable.
// Converted to StringLiteral in analyze, if this variable is not exist, throw AnalysisException.
public class VariableExpr extends Expr {
@SerializedName("n")
private String name;
@SerializedName("st")
private SetType setType;
private boolean isNull;
private boolean boolValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import org.apache.doris.common.AnalysisException;

import com.google.common.base.Strings;
import com.google.gson.annotations.SerializedName;

import java.io.StringWriter;

public class Separator {
private static final String HEX_STRING = "0123456789ABCDEF";

@SerializedName("os")
private final String oriSeparator;
@SerializedName("s")
private String separator;

public Separator(String separator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,29 @@
import org.apache.doris.load.loadv2.LoadTask;

import com.google.common.base.Strings;
import com.google.gson.annotations.SerializedName;

import java.util.List;

public class RoutineLoadDesc {
@SerializedName("cs")
private final Separator columnSeparator;
@SerializedName("ld")
private final Separator lineDelimiter;
@SerializedName("cols")
private final List<ImportColumnDesc> columnsInfo;
@SerializedName("pf")
private final Expr precedingFilter;
@SerializedName("f")
private final Expr filter;
@SerializedName("dc")
private final Expr deleteCondition;
@SerializedName("mt")
private LoadTask.MergeType mergeType;
// nullable
@SerializedName("pn")
private final PartitionNamesInfo partitionNamesInfo;
@SerializedName("sc")
private final String sequenceColName;

public RoutineLoadDesc(Separator columnSeparator, Separator lineDelimiter, List<ImportColumnDesc> columnsInfo,
Expand Down
Loading