Skip to content

Commit

Permalink
Fix VARCHAR(x) related failures in TestArrayOperators
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Osipiuk authored and pnowojski committed Dec 30, 2015
1 parent 417a067 commit f0b5c9f
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ public void testArrayMin()
assertFunction("ARRAY_MIN(ARRAY [NULL, NULL, NULL])", UNKNOWN, null);
assertFunction("ARRAY_MIN(ARRAY [NULL, 2, 3])", BIGINT, null);
assertFunction("ARRAY_MIN(ARRAY [1.0, NULL, 3])", DOUBLE, null);
assertFunction("ARRAY_MIN(ARRAY ['1', '2', NULL])", VARCHAR, null);
assertFunction("ARRAY_MIN(ARRAY ['1', '2', NULL])", createVarcharType(1), null);
assertFunction("ARRAY_MIN(ARRAY [3, 2, 1])", BIGINT, 1);
assertFunction("ARRAY_MIN(ARRAY [1, 2, 3])", BIGINT, 1);
assertFunction("ARRAY_MIN(ARRAY [1, 2.0, 3])", DOUBLE, 1.0);
assertFunction("ARRAY_MIN(ARRAY [ARRAY[1, 2], ARRAY[3]])", new ArrayType(BIGINT), ImmutableList.of(1L, 2L));
assertFunction("ARRAY_MIN(ARRAY [1.0, 2.5, 3.0])", DOUBLE, 1.0);
assertFunction("ARRAY_MIN(ARRAY ['puppies', 'kittens'])", VARCHAR, "kittens");
assertFunction("ARRAY_MIN(ARRAY ['puppies', 'kittens'])", createVarcharType(7), "kittens");
assertFunction("ARRAY_MIN(ARRAY [TRUE, FALSE])", BOOLEAN, false);
assertFunction("ARRAY_MIN(ARRAY [NULL, FALSE])", BOOLEAN, null);
}
Expand All @@ -322,13 +322,13 @@ public void testArrayMax()
assertFunction("ARRAY_MAX(ARRAY [NULL, NULL, NULL])", UNKNOWN, null);
assertFunction("ARRAY_MAX(ARRAY [NULL, 2, 3])", BIGINT, null);
assertFunction("ARRAY_MAX(ARRAY [1.0, NULL, 3])", DOUBLE, null);
assertFunction("ARRAY_MAX(ARRAY ['1', '2', NULL])", VARCHAR, null);
assertFunction("ARRAY_MAX(ARRAY ['1', '2', NULL])", createVarcharType(1), null);
assertFunction("ARRAY_MAX(ARRAY [3, 2, 1])", BIGINT, 3);
assertFunction("ARRAY_MAX(ARRAY [1, 2, 3])", BIGINT, 3);
assertFunction("ARRAY_MAX(ARRAY [1, 2.0, 3])", DOUBLE, 3.0);
assertFunction("ARRAY_MAX(ARRAY [ARRAY[1, 2], ARRAY[3]])", new ArrayType(BIGINT), ImmutableList.of(3L));
assertFunction("ARRAY_MAX(ARRAY [1.0, 2.5, 3.0])", DOUBLE, 3.0);
assertFunction("ARRAY_MAX(ARRAY ['puppies', 'kittens'])", VARCHAR, "puppies");
assertFunction("ARRAY_MAX(ARRAY ['puppies', 'kittens'])", createVarcharType(7), "puppies");
assertFunction("ARRAY_MAX(ARRAY [TRUE, FALSE])", BOOLEAN, true);
assertFunction("ARRAY_MAX(ARRAY [NULL, FALSE])", BOOLEAN, null);
}
Expand Down Expand Up @@ -422,10 +422,11 @@ public void testElementAt()
assertFunction("ELEMENT_AT(ELEMENT_AT(ARRAY [ARRAY[1, 2], ARRAY [3]], -1) , 1)", BIGINT, 3);
assertFunction("ELEMENT_AT(ELEMENT_AT(ARRAY [ARRAY[1, 2], ARRAY [3]], 2) , -1)", BIGINT, 3);
assertFunction("ELEMENT_AT(ELEMENT_AT(ARRAY [ARRAY[1, 2], ARRAY [3]], -1) , -1)", BIGINT, 3);
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens'], 2)", VARCHAR, "kittens");
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens'], -1)", VARCHAR, "kittens");
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens', NULL], 3)", VARCHAR, null);
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens', NULL], -1)", VARCHAR, null);
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens'], 2)", createVarcharType(7), "kittens");
assertFunction("ELEMENT_AT(ARRAY ['crocodiles', 'kittens'], 2)", createVarcharType(10), "kittens");
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens'], -1)", createVarcharType(7), "kittens");
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens', NULL], 3)", createVarcharType(7), null);
assertFunction("ELEMENT_AT(ARRAY ['puppies', 'kittens', NULL], -1)", createVarcharType(7), null);
assertFunction("ELEMENT_AT(ARRAY [TRUE, FALSE], 2)", BOOLEAN, false);
assertFunction("ELEMENT_AT(ARRAY [TRUE, FALSE], -1)", BOOLEAN, false);
assertFunction("ELEMENT_AT(ARRAY [from_unixtime(1), from_unixtime(100)], 1)", TIMESTAMP, sqlTimestamp(1000));
Expand Down Expand Up @@ -489,7 +490,7 @@ public void testSlice()
assertFunction("SLICE(ARRAY [1, 2, 3, 4, 5], 1, 4)", new ArrayType(BIGINT), ImmutableList.of(1L, 2L, 3L, 4L));
assertFunction("SLICE(ARRAY [1, 2], 1, 4)", new ArrayType(BIGINT), ImmutableList.of(1L, 2L));
assertFunction("SLICE(ARRAY [1, 2, 3, 4, 5], 3, 2)", new ArrayType(BIGINT), ImmutableList.of(3L, 4L));
assertFunction("SLICE(ARRAY ['1', '2', '3', '4'], 2, 1)", new ArrayType(VARCHAR), ImmutableList.of("2"));
assertFunction("SLICE(ARRAY ['1', '2', '3', '4'], 2, 1)", new ArrayType(createVarcharType(1)), ImmutableList.of("2"));
assertFunction("SLICE(ARRAY [1, 2, 3, 4], 3, 3)", new ArrayType(BIGINT), ImmutableList.of(3L, 4L));
assertFunction("SLICE(ARRAY [1, 2, 3, 4], -3, 3)", new ArrayType(BIGINT), ImmutableList.of(2L, 3L, 4L));
assertFunction("SLICE(ARRAY [1, 2, 3, 4], -3, 5)", new ArrayType(BIGINT), ImmutableList.of(2L, 3L, 4L));
Expand Down Expand Up @@ -701,7 +702,7 @@ public void testArrayRemove()
assertFunction("ARRAY_REMOVE(ARRAY [TRUE, FALSE, TRUE], TRUE)", new ArrayType(BOOLEAN), ImmutableList.of(false));
assertFunction("ARRAY_REMOVE(ARRAY [TRUE, FALSE, TRUE], FALSE)", new ArrayType(BOOLEAN), ImmutableList.of(true, true));
assertFunction("ARRAY_REMOVE(ARRAY [NULL, FALSE, TRUE], TRUE)", new ArrayType(BOOLEAN), asList(null, false));
assertFunction("ARRAY_REMOVE(ARRAY [ARRAY ['foo'], ARRAY ['bar'], ARRAY ['baz']], ARRAY ['bar'])", new ArrayType(new ArrayType(VARCHAR)), ImmutableList.of(ImmutableList.of("foo"), ImmutableList.of("baz")));
assertFunction("ARRAY_REMOVE(ARRAY [ARRAY ['foo'], ARRAY ['bar'], ARRAY ['baz']], ARRAY ['bar'])", new ArrayType(new ArrayType(createVarcharType(3))), ImmutableList.of(ImmutableList.of("foo"), ImmutableList.of("baz")));
}

public void assertInvalidFunction(String projection, SemanticErrorCode errorCode)
Expand Down

2 comments on commit f0b5c9f

@martint
Copy link

@martint martint commented on f0b5c9f Jan 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be squashed with the commit that implements varchar(n)

@pnowojski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we left those patches alone to ease reviewing process (as I remember Christopher Berner asked for this).

merged with implement varchar(n)

Please sign in to comment.