English 中文(简体)
经营人之间使用维生不平等
原标题:Hive inequality join using between operator

我们有一个类似以下查询的查询:(分区_日期是我们的表格分区)

SELECT * FROM A
JOIN B 
where partition_date > B.last_runtime;

我们认识到,通过将该条件置于 条款中,该条件导致整个表格扫描,因此我们需要将其作为 ON 放在 JOIN 中。

问题在于蜂窝不支持不平等, 考虑使用以下 < code> BETween 操作器:

Select * from A
JOIN B ON par_date between B.last_runtime and  99999999 ;

this is giving us the error: Both left and right aliases encountered in JOIN 99999999

如果我用实际值取代B. Last_runtime, 说20160310有效...

有什么想法吗?

问题回答

A 之间 B 和 C < / code> 翻译为 A 大于或等于 B 和 A 小于或等于 C < / em >, 所以我认为它仍然是非二次。

然而,我无法解释错误信息的含义。 它抛出< a href="https://github.com/apache/hive/blob/0d379021e7b1if76572bc856d120642148d137/ql/ src/java/org/apache/hadoop/hive/ql/optiminizer/calcite/translator/JoinCondTypeCheckProcfactory.java#L119" rel="no fol" >here , 如果您想分析源代码:

private static boolean hasTableAlias(JoinTypeCheckCtx ctx, String tabName, ASTNode expr)
    throws SemanticException {
  int tblAliasCnt = 0;
  for (RowResolver rr : ctx.getInputRRList()) {
    if (rr.hasTableAlias(tabName))
      tblAliasCnt++;
  }

  if (tblAliasCnt > 1) {
    throw new SemanticException(ErrorMsg.INVALID_JOIN_CONDITION_1.getMsg(expr));
  }

  return (tblAliasCnt == 1) ? true : false;
}

在加入条件期间, hive 将不支持任何操作, 如 ; , ; ,

select A.Name, A.Address, B.salary from Person_details as A left join Person_earnings as B on (B.salary > 15000) 

<强 > 而不是

select A.Name, A.Address, B.salary from Person_details as A left join Person_earnings as B on (A.Id=B.Id) where B.salary > 15000

首先,应当开展平等行动,随后可以适用其他条件,由于蜂窝用于大型数据集,它只是首先支持平等条件。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...