Cloudera Imapala: Руководство начинающего / Cloudera Imapala: Tutorials for Getting Started

→With Impala 1.2.2, we rewrite the query slightly to use CROSS JOIN rather than JOIN, and now the result set includes all combinations:
0 Impala 1.2.2 позволяет изменить запрос заменив JOIN на CROSS JOIN и получить требуемую комбинацию.
→Readers demanded more action, so we added elements of time travel and space travel so that any hero could face any villain. Prior to Impala 1.2.2, this type of query was impossible because all joins had to reference matching values between the two tables:
0 Читателям нравится экшен, так что добавим путешествия во врмени и пространстве что бы любой из героев мог встретиться с любым их злодеев. В версиях Impala раньше 1.2.2 такой запрос был бы невозможен - условие объединения было обязательным.
→The following example sets up data for use in a series of comic books where characters battle each other. At first, we use an equijoin query, which only allows characters from the same time period and the same planet to meet.
0 Данный пример показывает запрос, генерирующий сценарий комикса, в котором каждый супер герой будет иметь возможность сразиться с каждым из злодеев. Для начала мы выполним объединяющий запрос с равенством, который позволит встретиться только тем, кто находится в одном месте и эпохе.
→In Impala 1.2.2 and higher, this restriction is lifted when you use the CROSS JOIN operator in the query. You still cannot remove all WHERE clauses from a query like SELECT * FROM t1 JOIN t2 to produce all combinations of rows from both tables. But you can use the CROSS JOIN operator to explicitly request such a Cartesian product. Typically, this operation is applicable for smaller tables, where the result set still fits within the memory of a single Impala node.
0 В версии Impala 1.2.2 и выше, ограничение можно обойти используя оператор CROSS JOIN. Часть WHERE при этом остается обязательной в выражении SELECT * FROM t1 JOIN t2 для обработки всех комбинаций обеих таблиц. Использование же CROSS JOIN позволяет получить декартово равенство. Данное выражение допустимо для неболших таблиц, размер которых меньше оперативной памяти одной из нод Impala.
→Originally, Impala restricted join queries so that they had to include at least one equality comparison between the columns of the tables on each side of the join operator. With the huge tables typically processed by Impala, any miscoded query that produced a full Cartesian product as a result set could consume a huge amount of cluster resources.
0 Изначально, запросы с JOIN в Impala были ограничены обязательным наличием хотя бы одного сравнения колонок таблиц для обехи сторон. При обратоке большых таблиц, любой ошибочный запрос выполняющий декартово равенство мог потреблять огромное количество ресурсов кластера.
→Cross Joins and Cartesian Products with the CROSS JOIN Operator
0 Объединение таблиц c помощью CROSS JOIN
→Prior to Impala 1.2, the REFRESH and INVALIDATE METADATA statements needed to be issued on each Impala node to which you connected and issued queries. In Impala 1.2 and higher, when you issue either of those statements on any Impala node, the results are broadcast to all the Impala nodes in the cluster, making it truly a one-step operation after each round of DDL or ETL operations in Hive.
0 В версиях предшествовавших Impala 1.2 операции REFRESH и INVALIDATE METADATA нужно было выполнять на каждой их нод. Начиная с 1.2 при выполнении на одной из нод, результат распространяется на все ноды кластера, упрощая процесс обновления данных после выполнения DDL и ETL операций средствами Hive до одного шага.
→Note:
Originally, Impala did not support UDFs, but this feature is available in Impala starting in Impala 1.2. Some INSERT ... SELECT transformations that you originally did through Hive can now be done through Impala. See User-Defined Functions (UDFs) for details.
0 Примечание. До версии Impala 1.2 пользовательские операции не поддерживались. Некоторые INSERT ... SELECT функции изначально доступные только в Hive теперь могут быть выполнены и средствами Implala. См Пользовательские функции (UDFs).
→For examples showing how this process works for the INVALIDATE METADATA statement, look at the example of creating and loading an Avro table in Hive, and then querying the data through Impala. See Using the Avro File Format with Impala Tables for that example.
0 Что бы понять как работает INVALIDATE METADATA , посмотрите на пример создания и заполнения таблицы Avro средствами Hive, а затем опрошенных через Impala. Обратите внимание на использование Avro таблиц Impala.
→For examples showing how this process works for the REFRESH statement, look at the examples of creating RCFile and SequenceFile tables in Impala, loading data through Hive, and then querying the data through Impala. See Using the RCFile File Format with Impala Tables and Using the SequenceFile File Format with Impala Tables for those examples.
0 Что бы понять как работает REFRESH, посмотрите на пример создания таблиц RCFile и SequenceFile средствами impala, загруженных через Hive а затем опрошенных через Impala. Обратите внимание на использование RCFile и SequenceFile таблиц Impala.
→Whenever you load, insert, or change data in an existing table through Hive (or even through manual HDFS operations such as the hdfs command), the next time you switch back to the impala-shell interpreter, issue a one-time REFRESH table_name statement so that Impala recognizes the new or changed data.
0 При выполнении load, insert или change средствами Hive (или даже вручную через команды HDFS), в командной строке Impala достаточно выполнить REFRESH имя_таблицы для того что бы Impala были опознаны изменения.
→Whenever you create, drop, or alter a table or other kind of object through Hive, the next time you switch back to the impala-shell interpreter, issue a one-time INVALIDATE METADATA statement so that Impala recognizes the new or changed object.
0 После выполнения операций удалении или изменения таблицы средствами Hive, у вас есть возможность выполнив в командной строке INVALIDATE METADATA заставить Impala перечитать измененные данные объекта.
→Sometimes, you might find it convenient to switch to the Hive shell to perform some data loading or transformation operation, particularly on file formats such as RCFile, SequenceFile, and Avro that Impala currently can query but not write to.
0 Иногда, возникает необходимость использовать командную строку Hive для загрузки или передачи или изменения данных. Из Impala доступны для чтения такие форматы файлов как RCFile, SequenceFile и Avro Impala. Запись в этих форматах не поддерживается.
→Switching Back and Forth Between Impala and Hive
0 Возвращение от Impala к Hive
→We issue a REFRESH statement for the table, always a safe practice when data files have been manually added, removed, or changed. Then the data is ready to be queried. The SELECT * statement illustrates that the data from our trivial CSV file was recognized in each of the partitions where we copied it. Although in this case there are only a few rows, we include a LIMIT clause on this test query just in case there is more data than we expect.
0 Используем выражение REFRESH каждый раз когда была добавлена, изменана или удалена хотя бы одна из партиций. Данные готовы для выполнения запросов. Выражение SELECT * показывает, что рновые данные успешно распознаны в каждой из папок. Выведено всего несколько строчек так как мы воспользовались оператором LIMIT на случай если будет получено больше данных чем мы ожидаем.
→Because partition subdirectories and data files come and go during the data lifecycle, you must identify each of the partitions through an ALTER TABLE statement before Impala recognizes the data files they contain.
0 Так как подпапки-партиции были добавлены после содания таблицы, для того что бы они данные в них доступны Impala, каждую из них необходимо идентифицировать помощью ALTER TABLE.
→Back in the impala-shell interpreter, we move the original Impala-managed table aside, and create a new external table with a LOCATION clause pointing to the directory under which we have set up all the partition subdirectories and data files.

0 Снова запустив интерпретатор impala-shell, переместив таблицу контролируемую Impala и с помощью оператора LOCATION создадим новую внешнюю таблицу, указывающую на на только что созданную папку, содержащую папки с данными.
→We make a tiny CSV file, with values different than in the INSERT statements used earlier, and put a copy within each subdirectory that we will use as an Impala partition.
0 Мы создаем небольшой CSV файл, с данными отличными от тех что были добавлены с помощью INSERT. Создадим копии этого файла во всех подпапках, использующихся для партиционирования.
→Still in the Linux shell, we use hdfs dfs -mkdir to create several data directories outside the HDFS directory tree that Impala controls (/user/impala/warehouse in this example, maybe different in your case). Depending on your configuration, you might need to log in as a user with permission to write into this HDFS directory tree; for example, the commands shown here were run while logged in as the hdfs user.
0 Не покидая командной строки Linux, выполним hdfs dfs -mkdir для создания нескольких папок на HDFS с данным за пределами рабочей папки Impala (расположение может отличаться, в нашем случае это /user/impala/warehouse). В зависимости от настроек, возможно придется авторизоваться под пользоватлем, обладающим правами на запись в этой папке HDFS; Ниже приведен пример команд, которые нужно выполнить с правами такого пользователя.
→Back in the Linux shell, we examine the HDFS directory structure. (Your Impala data directory might be in a different location; for historical reasons, it is sometimes under the HDFS path /user/hive/warehouse.) We use the hdfs dfs -ls command to examine the nested subdirectories corresponding to each partitioning column, with separate subdirectories at each level (with = in their names) representing the different values for each partitioning column. When we get to the lowest level of subdirectory, we use the hdfs dfs -cat command to examine the data file and see CSV-formatted data produced by the INSERT statement in Impala.
0 Вернемся в командную строку linux и проверим структуру каталогов HDFS. (В вашем случае расположение рабочей папки Impala может отличаться, по историческим причином она часто располагается в /user/hive/warehouse). Воспользуемся командой hdfs dfs -ls что бы посмотреть подпапки, относящиеся к кажой подпапке. Добравшись до последней папки и воспользовавшись командой hdfs dfs -cat для просмотра содержимого файла, мы увидим данные в CSV формате, ставшие результатом выполнения INSERT.
Резюме
Пол:
мужчина
Родной язык:
русский
С нами:
с 1 мая 2010 г. (6014 дней)
Не является членом клуба.
Деятельность:
357 версий перевода с общим рейтингом 5
12 комментариев
Карма: 1 (оценок: 1)
Написать nipman личное сообщение