by simonc » Mon Jul 07, 2014 6:37 am
When I do a SELECT I don’t seem to be able to get the PK of a row. Example:
aql> select firstName, PK from test.user
+-----------------+
| firstName |
+-----------------+
| "firstNameTEST" |
+-----------------+
When I do “SELECT * from test.user” I don’t the PK either. How can I include the PK in a SELECT?
1 Like
by Bhuvana » Wed Jul 09, 2014 11:51 am
Hi Simonc,
Which version of Aerospike (server, client) are you using ?
We have recently added the ability to store and retrieve primary-keys along with the other bins in the record. This is specific to the C-client and I dont think other clients support it yet. There is no tools/AQL support for this yet.
Thanks
Bhuvana
I am using AeroSpike Server Community Edition 3.3.12 and AeroSpike Python Client 1.0.27
which does not have support to SELECT PK along with bins.
- When AeroSpike will add this MUST needed functionality to Python Client?
- Is there any way to see “what all keys are in my cluster?”
I appreciate if AeroSpike’s product management can share some info. here.
Thanks,
DJ
In the Python client release 1.0.30 the default behavior is to send the key:
pip search aerospike
aerospike - Aerospike Client Library for Python
INSTALLED: 1.0.30 (latest)
The following script
from __future__ import print_function
import aerospike
import sys
try:
client = aerospike.client({ 'hosts': [ ('192.168.119.183', 3000) ] }).connect()
try:
record = { 'foo' : 'bar', 'a' : 1, 'z' : 26 }
client.put(('test', 'demo', 'd'), record)
(key, metadata, record) = client.get(('test', 'demo', 'd'))
print(key)
print(metadata)
print(record)
except Exception as e:
print("error: {0}".format(e), file=sys.stderr)
sys.exit(1)
client.close()
except Exception as e:
print("Could not connect! ".format(e), file=sys.stderr)
sys.exit(2)
sys.exit(0)
Produces this output. Notice that the key is present:
('test', 'demo', u'd', bytearray(b'\xc4\xed\x01\x1aXT\xe1\x85\xc8\xbd\xb4\n1\xd6z$\x9ak\xb0\x17'))
{'gen': 1, 'ttl': 432000}
{'a': 1, 'foo': u'bar', 'z': 26}
Later releases will include the ability to explicitly set the key policy.
still it is not supported in aql ?
EXPLAIN requires PK as condition to show any record. So is this really possible to see primary key usiing EXPLAIN ?
@rbotzer
Ignore my previous post. However it’s being worked on now.