Invalid table name with table search - google-bigquery

In BigQuery I am using the following query:
SELECT
*
FROM
`properati-data-public:properties_mx.properties_sell_201***`
WHERE
_TABLE_SUFFIX BETWEEN '1501'
AND '1810'
Where properati-data-public:properties_mx.properties_sell_201501 is a valid table. When I use the query with multiple tables, I get the following error:
Query Failed
Error: Invalid table name: `properati-data-public:properties_mx.properties_sell_201***`

you should use:
`properati-data-public.properties_mx.properties_sell_20*`
Note:
. vs. :
20* vs. 201***
Also put below as a first line in your query to assure you are in Standard SQL mode
#standardSQL

Related

Hive conditionally select column name

I have multiple tables with very similar schema except one column, which can have different names.
I want to make some complicated calculations using Hive and would like to have one code for all tables with possible parametrisation. For some reasons, I can't parametrise queries using language like Python, Scala etc, so decided to go with pure Hive SQL.
I want to conditionally select appropriate column, but it seems, that Hive evaluates all parts of conditional expression/statement regardless of condition.
What did I wrong?
DROP TABLE IF EXISTS `so_sample`;
CREATE TABLE `so_sample` (
`app_version` string
);
SELECT
if (true, app_version, software_version) AS firmware
FROM so_sample
;
Output:
Error: Error while compiling statement: FAILED: SemanticException [Error 10004]: Line 2:25 Invalid table alias or column reference 'software_version': (possible column names are: app_version) (state=42000,code=10004)
Regards
Pawel
Try to use regex to select the column with different names, for more information see manual and don't forget
set hive.support.quoted.identifiers=none;

psql column doesn't exist but it does

I am trying to select a single column in my data table using raw SQL in a postgresql database from the psql command line. I am getting an error message that says the column does not exist. Then it gives me a hint to use the exact column that I referenced in the select statement. Here is the query:
SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;
Here is the error message:
ERROR: column insider_app_ownershipdocument.transactiondate does not exist
SELECT insider_app_ownershipdocument.transactionDate FROM in...
HINT: Perhaps you meant to reference the column "insider_app_ownershipdocument.transactionDate".
I have no idea why this is not working.
(Postgres) SQL converts names automatically to lower case although it support case-sensitive names. So
SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;
will be aquivalent to:
SELECT insider_app_ownershipdocument.transactiondate FROM insider_app_ownershipdocument;
You should protect the column name with double quotes to avoid this effect:
SELECT insider_app_ownershipdocument."transactionDate" FROM insider_app_ownershipdocument;

SELECT database.table.column in Hive

Is it possible to use
SELECT DB.TABLE.COLUMN from DB.TABLE
in Hive?
I know it's possible to alias DB.TABLE as follows
SELECT T1.COLUMN FROM DB.TABLE AS T1
But, is there any way in Hive to select a column fully qualified by its database and table name, as shown in the first query above? I've done this before in MySQL but I don't know if there's a way to make Hive work this way.
No, that is not possible in Hive, you will get an exception:
SemanticException [Error 10004]: Line 1:7 Invalid table alias or column reference 'DB': (possible column names are: col)
And your second select sentence is valid.
To specify a database, either qualify the table names with database names ("db_name.table_name" starting in Hive 0.7) or issue the USE statement before the query statement (starting in Hive 0.6).
See language manual here: LanguageManual+Select

how to get databases names in sqlite3?

I'm trying to valid a SQL injection challenge on root-me.org. I want to retrieve the databases names with the command
1' SELECT * FROM my_db.sqlite_master WHERE type='table';
But i get the following error: SQLite3::query(): Unable to prepare statement: 1, near "SELECT"
Any idea ?
SELECT name
FROM master.dbo.sysdatabases
Possible duplicate of
sqlite3 - how to list out database name using .databases command?

Unable to determine schema of SELECT * in this query

I have created a table in Bigquery using the data personsData.json and schema personsDataSchema.json provided by the documentation at https://developers.google.com/bigquery/docs/data#nested.
This query works fine:
SELECT children.* FROM dw_test.persons
But the following query gives the error Error: 0.0 - 0.0: Unable to determine schema of SELECT * in this query:
SELECT citiesLived.* FROM dw_test.persons
I understand that a workaround will be to simply list all the fields of citiesLived:
SELECT citiesLived.place, citiesLived.yearsLived FROM dw_test.persons
But in the case when the record has many fields, listing all the fields becomes cumbersome.
Could anyone please help?
Thank you so much.