Skip to content
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

Added more tests for the RequestParser class and refactored the old ones. #491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.NotImplementedException;
Expand Down Expand Up @@ -334,13 +335,13 @@ List<RequestColumn> generateRequestColumnsWithProject( String projectionString,
LogicalColumn logicalColumn = this.getCatalogColumnFromString( columnName );
log.debug( "Fetched catalog column for projection key: {}.", columnName );

if ( !validColumns.contains( logicalColumn.id ) ) {
if ( !validColumns.contains( logicalColumn.getId() ) ) {
log.warn( "Column isn't valid. Column: {}.", columnName );
throw new ParserException( ParserErrorCode.PROJECTION_INVALID_COLUMN, columnName );
}

projectedColumns.add( logicalColumn.id );
int calculatedPosition = tableOffsets.get( logicalColumn.tableId ) + logicalColumn.position - 1;
projectedColumns.add( logicalColumn.getId() );
int calculatedPosition = tableOffsets.get( logicalColumn.getTableId() ) + logicalColumn.getPosition() - 1;
RequestColumn requestColumn = new RequestColumn( logicalColumn, calculatedPosition, internalPosition, matcher.group( "alias" ), this.decodeAggregateFunction( matcher.group( "agg" ) ) );
internalPosition++;

Expand Down Expand Up @@ -550,7 +551,7 @@ Filters parseFilters( Map<String, String[]> filterMap, Map<String, RequestColumn

for ( String filterString : filterMap.get( possibleFilterKey ) ) {
Pair<Operator, String> rightHandSide = this.parseFilterOperation( filterString );
PolyValue literal = this.parseLiteralValue( catalogColumn.getColumn().type, rightHandSide.right );
PolyValue literal = this.parseLiteralValue( catalogColumn.getColumn().getType(), rightHandSide.right );
// TODO: add column filters here
literalFilterOperators.add( new Pair<>( rightHandSide.left, literal ) );
}
Expand Down Expand Up @@ -747,6 +748,7 @@ public Map<String, LogicalColumn> generateNameMapping( List<LogicalTable> tables


@AllArgsConstructor
@Getter
public static class Filters {

public final Map<RequestColumn, List<Pair<Operator, PolyValue>>> literalFilters;
Expand Down
Loading