Why I can't force to work these queries:
select '2018-09-10 03:00:00+03'::timestamptz <-> '2018-09-10 03:00:00+03'::timestamptz
select * from T
order by time <-> '2018-09-10 03:00:00+03'::timestamptz
limit 1
Error: operator does not exist: timestamp with time zone <-> timestamp with time zone
I also tried to install pg_trgm.
PostgreSQL 12.2
btree_gist 1.5
Windows Server 2012 R2
What I did wrong?
Related
I have a database that was using postgis 2.2.1 extension on postgresql 9.5 database on server A. But, recently I have upgraded this to 2.5.5 and copied this database to new server B which also has postgis 2.5.5. Result of Postgis_full_version() on A is:
POSTGIS="2.5.5" [EXTENSION] PGSQL="95" GEOS="3.7.1-CAPI-1.11.1 27a5e771" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.11.99" LIBPROTOBUF="1.2.1" RASTER
and same for server B is:
POSTGIS="2.5.5" [EXTENSION] PGSQL="95" GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 6.3.1, February 10th, 2020" GDAL="GDAL 3.0.4, released 2020/01/28" LIBXML="2.9.10" LIBJSON="0.13.1" LIBPROTOBUF="1.3.3" RASTER
On server B, the database is throwing error when using ESPG 27200 in ST_transform queries but working for other ESPG projections.
For example, when I am executing query:
select st_asText(st_transform(st_geomfromtext('POINT(172 -43)', 4326), 27200));
I am getting this error:
NOTICE: PostGIS was unable to transform the point because either no grid shift files were found, or the point does not lie within the range for which the grid shift is defined. Refer to the ST_Transform() section of the PostGIS manual for details on how to configure PostGIS to alter this behaviour.
ERROR: transform: couldn't project point (172 -43 0): failed to load datum shift file (-38)
SQL state: XX000
Difference between server A and server B config is A is running on GDAL 1.11
I am a newbie to postgresql and postgis, so I am not sure how to fix the problem.
The official Postgresql recognized timezones says Iran Time is IT so why I get this error? It's version 12 if matters.
postgres=# alter role myuser set timezone to 'IT';
ERROR: invalid value for parameter "TimeZone": "IT"
Well, you shouldn't read the manual of outdated and discontinued versions. The fact that the page doesn't exist any longer for supported versions should have made you suspicious.
Modern Postgres versions provide the view pg_timezone_names to check for valid timezone names.
If you run
select *
from pg_timezone_names
where name ilike '%iran%'
you will get this result:
name
abbrev
utc_offset
is_dst
Europe/Tirane
CET
01:00:00
f
posix/Europe/Tirane
CET
01:00:00
f
posix/Iran
+0330
03:30:00
f
Iran
+0330
03:30:00
f
so there is no such abbreviation (any more). You will need to use the name:
alter role myuser set timezone to 'Iran';
Note that the result also depends on the operating system on which the Postgres server is running. On Windows you wouldn't get the posix time zones.
I am trying to create a partitioned table in edb 9.6.10 . I am getting the following error when I am trying to do so
edb=# create table employee (id int, join_date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL ('1 day'::interval);
ERROR: syntax error at or near "INTERVAL"
LINE 1: ...date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL (...
^
Please let me know what I am doing wrong here.
As far as I can tell, the feature you are trying to use only exists in EDB's paid product, and even there it only became available in v12.
This PARTITION BY RANGE INTERVAL is only supported from version 12 and onward.
See the difference of behaviour for the same query in version11 and version12.
edb=# select version;
PostgreSQL 11.11 (EnterpriseDB Advanced Server 11.11.20) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)
edb=# create table employee (id int, join_date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL ('1 day'::interval);
ERROR: syntax error at or near "INTERVAL"
LINE 1: ...date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL (...
and in Version12 we get
edb=# select version();
PostgreSQL 12.4 (EnterpriseDB Advanced Server 12.4.5) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)
edb=# create table employee (id int, join_date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL ('1 day'::interval);
CREATE TABLE
Moreover, this 'INTERVAL' syntax is only available in EnterpriseDB paid product. In the case of community Postgres e.g V13 you will still get the same error.
[root#localhost bin]# ./psql -U postgres -d postgres -p 5432
psql (13.2)
Type "help" for help.
postgres=# create table employee (id int, join_date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL ('1 day'::interval);
ERROR: syntax error at or near "INTERVAL"
LINE 1: ...date timestamp(6)) PARTITION BY RANGE (join_date) INTERVAL (...
My Unix Spark Server timezone is CDT but when I'm running Beam SQL CURRENT_TIMESTAMP as below it is always coming as UTC. I tried locally also but it is always displaying UTC. I want this to be CDT same as server zone in CURRENT_TIMESTAMP function. Can you please advise fix for this?
PCollection<Row> cnct = testApps
.apply(SqlTransform.query("SELECT current_timestamp as ts "
+ "FROM PCOLLECTION"));
I am running a SQL query and trying to break the results down into chunks.
select task_id, owner_cnum
from (select row_number() over(order by owner_cnum, task_id)
as this_row, wdpt.vtasks.*
from wdpt.vtasks)
where this_row between 1 and 5;
That SQL works with DB2 10.5 on Windows and Linux, but fails on DB2 10.1 on z/OS with the following error messages:
When I run the SQL from IBM DataStudio 4.1.1 running on my Windows machine connected to the database, I am getting:
ILLEGAL SYMBOL "<EMPTY>". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: CORRELATION NAME. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.18.60
When I run my Java program on a zLinux system connecting to the database, I get the following error:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<EMPTY>;CORRELATION NAME, DRIVER=3.65.97
Any ideas what I'm doing wrong?
In some DB2 versions you must use a correlation name for a subselect, as suggested by the error message:
select FOO from (
select FOO from BAR
) as T
Here "T" is the correlation name.