Skip to content

Commit

Permalink
update .travis.yml to run against a specific hhvm version we support,… (
Browse files Browse the repository at this point in the history
#45)

* update .travis.yml to run against a specific hhvm version we support, since nightlies are not yet supported

* fix hhast-lint errors on 4.39
  • Loading branch information
Scott Sandler authored Jun 17, 2020
1 parent 30fbdd2 commit 3549042
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ sudo: required
language: generic
services: docker
env:
- HHVM_VERSION=4.16-latest
- HHVM_VERSION=latest
- HHVM_VERSION=nightly
- HHVM_VERSION=4.39-latest

install:
- docker pull hhvm/hhvm:$HHVM_VERSION
Expand Down
7 changes: 3 additions & 4 deletions src/Query/JoinProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ protected static function buildNaturalJoinFilter(dataset $left_dataset, dataset
if ($left === null || $right === null) {
throw new SQLFakeParseException("Attempted NATURAL join with no data present");
}
foreach ($left as $column => $val) {
foreach ($left as $column => $_val) {
$name = Str\split($column, '.') |> C\lastx($$);
foreach ($right as $col => $v) {
foreach ($right as $col => $_v) {
$colname = Str\split($col, '.') |> C\lastx($$);
if ($colname === $name) {
$filter = self::addJoinFilterExpression($filter, $column, $col);
Expand Down Expand Up @@ -242,7 +242,7 @@ private static function processHashJoin(
): dataset {
$left = $filter->left as ColumnExpression;
$right = $filter->right as ColumnExpression;
if ($left->tableName() === $right_table_name){
if ($left->tableName() === $right_table_name) {
// filter order may not match table order
// if the left filter is for the right table, swap the filters
list($left, $right) = vec[$right, $left];
Expand Down Expand Up @@ -285,7 +285,6 @@ private static function processHashJoin(
$any_match = false;
$value = $left->evaluate($row, $conn) |> static::coerceToArrayKey($$);
foreach ($right_dataset as $r) {
$candidate_row = Dict\merge($row, $r);
foreach ($right_temp_table[$value] ?? keyset[] as $k) {
$out[] = Dict\merge($row, $right_dataset[$k]);
$any_match = true;
Expand Down
44 changes: 29 additions & 15 deletions src/VitessQueryValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/

enum UnsupportedCases: string as string {
GroupByColumns = 'unsupported: in scatter query: group by column must reference column in SELECT list';
OrderByColumns = 'unsupported: in scatter query: order by column must reference column in SELECT list';
Unions = 'unsupported: UNION cannot be executed as a single route';
GROUP_BY_COLUMNS = 'unsupported: in scatter query: group by column must reference column in SELECT list';
ORDER_BY_COLUMNS = 'unsupported: in scatter query: order by column must reference column in SELECT list';
UNIONS = 'unsupported: UNION cannot be executed as a single route';
}

abstract class VitessQueryValidator {
Expand Down Expand Up @@ -42,7 +42,9 @@ public static function validate(Query $query, AsyncMysqlConnection $conn): void
public static function extractColumnExprNames(vec<Expression> $selectExpressions): keyset<string> {
$exprNames = keyset[];
foreach ($selectExpressions as $expr) {
if ($expr is ColumnExpression) { $exprNames[] = $expr->name; }
if ($expr is ColumnExpression) {
$exprNames[] = $expr->name;
}
}
return $exprNames;
}
Expand All @@ -55,8 +57,8 @@ public function __construct(public SelectQuery $query, public AsyncMysqlConnecti
<<__Override>>
public function getHandlers(): dict<string, (function(): Awaitable<void>)> {
return dict[
UnsupportedCases::GroupByColumns => inst_meth($this, 'scatterMustContainSelectColumns'),
UnsupportedCases::Unions => inst_meth($this, 'unionsNotAllowed'),
UnsupportedCases::GROUP_BY_COLUMNS => inst_meth($this, 'scatterMustContainSelectColumns'),
UnsupportedCases::UNIONS => inst_meth($this, 'unionsNotAllowed'),
];
}

Expand Down Expand Up @@ -105,30 +107,42 @@ private function isCrossShardQuery(): bool {

// check group by columns
foreach ($groupByCols ?? vec[] as $col) {
if (!$col is ColumnExpression) { continue; }
if (C\contains_key($exprNames, $col->name)) { continue; }
if (!$col is ColumnExpression) {
continue;
}
if (C\contains_key($exprNames, $col->name)) {
continue;
}

throw new SQLFakeVitessQueryViolation(
Str\format("Vitess query validation error: %s", UnsupportedCases::GroupByColumns),
Str\format("Vitess query validation error: %s", UnsupportedCases::GROUP_BY_COLUMNS),
);
}

// check order by columns
foreach ($orderByCols ?? vec[] as $col) {
if (!$col['expression'] is ColumnExpression) { continue; }
if (C\contains_key($exprNames, $col['expression']->name)) { continue; }
if (!$this->isCrossShardQuery()) { continue; }
if (!$col['expression'] is ColumnExpression) {
continue;
}
if (C\contains_key($exprNames, $col['expression']->name)) {
continue;
}
if (!$this->isCrossShardQuery()) {
continue;
}

throw new SQLFakeVitessQueryViolation(
Str\format("Vitess query validation error: %s", UnsupportedCases::OrderByColumns),
Str\format("Vitess query validation error: %s", UnsupportedCases::ORDER_BY_COLUMNS),
);
}
}

public async function unionsNotAllowed(): Awaitable<void> {
$query = $this->query;
$multiQueries = $query->multiQueries;
if (C\is_empty($multiQueries)) { return; }
if (C\is_empty($multiQueries)) {
return;
}

foreach ($multiQueries as $query) {
switch ($query['type']) {
Expand All @@ -137,7 +151,7 @@ private function isCrossShardQuery(): bool {
case MultiOperand::INTERSECT:
case MultiOperand::EXCEPT:
throw new SQLFakeVitessQueryViolation(
Str\format("Vitess query validation error: %s", UnsupportedCases::Unions),
Str\format("Vitess query validation error: %s", UnsupportedCases::UNIONS),
);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/InsertQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,5 @@ final class InsertQueryTest extends HackTest {
],
]);
}

}

0 comments on commit 3549042

Please sign in to comment.