项目作者: abetomo

项目描述 :
Convert AWS Athena QueryResults to Array.
高级语言: PHP
项目地址: git://github.com/abetomo/Convert-Athena-QueryResults-to-Array.git
创建时间: 2018-08-14T04:02:43Z
项目社区:https://github.com/abetomo/Convert-Athena-QueryResults-to-Array

开源协议:MIT License

下载


Convert-Athena-QueryResults-to-Array

Latest Stable Version
Test

Convert AWS Athena QueryResults to Array.
Since the response of GetQueryResults is complicated, it converts it to a simple array.

Installation

  1. % composer require abetomo/convert-athena-query-results-to-array

Usage

Convert the response of GetQueryResults into an array.

  1. <?php
  2. // ... startQueryExecution, etc.
  3. $getQueryResultsResponse = $athenaClient->getQueryResults([
  4. 'QueryExecutionId' => $queryExecutionId
  5. ]);
  6. use Abetomo\ConvertAthenaQueryResultstoArray\ConvertAthenaQueryResultstoArray;
  7. print "/// Original value\n";
  8. print_r($getQueryResultsResponse->get('ResultSet'));
  9. print "\n/// Convert to array \n";
  10. print_r(ConvertAthenaQueryResultstoArray::convert(
  11. $getQueryResultsResponse->get('ResultSet'),
  12. true // $isSkipHeader
  13. ));

Example of results

Convert to array

  1. Array
  2. (
  3. [0] => Array
  4. (
  5. [account_id] => id1
  6. [count] => 49
  7. )
  8. [1] => Array
  9. (
  10. [account_id] => id2
  11. [count] => 68
  12. )
  13. )

Original value

  1. Array
  2. (
  3. [Rows] => Array
  4. (
  5. [0] => Array
  6. (
  7. [Data] => Array
  8. (
  9. [0] => Array
  10. (
  11. [VarCharValue] => account_id
  12. )
  13. [1] => Array
  14. (
  15. [VarCharValue] => count
  16. )
  17. )
  18. )
  19. [1] => Array
  20. (
  21. [Data] => Array
  22. (
  23. [0] => Array
  24. (
  25. [VarCharValue] => id1
  26. )
  27. [1] => Array
  28. (
  29. [VarCharValue] => 49
  30. )
  31. )
  32. )
  33. [2] => Array
  34. (
  35. [Data] => Array
  36. (
  37. [0] => Array
  38. (
  39. [VarCharValue] => id2
  40. )
  41. [1] => Array
  42. (
  43. [VarCharValue] => 68
  44. )
  45. )
  46. )
  47. )
  48. [ResultSetMetadata] => Array
  49. (
  50. [ColumnInfo] => Array
  51. (
  52. [0] => Array
  53. (
  54. [CatalogName] => hive
  55. [SchemaName] =>
  56. [TableName] =>
  57. [Name] => account_id
  58. [Label] => account_id
  59. [Type] => varchar
  60. [Precision] => 2147483647
  61. [Scale] => 0
  62. [Nullable] => UNKNOWN
  63. [CaseSensitive] => 1
  64. )
  65. [1] => Array
  66. (
  67. [CatalogName] => hive
  68. [SchemaName] =>
  69. [TableName] =>
  70. [Name] => count
  71. [Label] => count
  72. [Type] => integer
  73. [Precision] => 10
  74. [Scale] => 0
  75. [Nullable] => UNKNOWN
  76. [CaseSensitive] =>
  77. )
  78. )
  79. )
  80. )