I have one 'q' service running. I want to check whether current directory in the service is a partitioned directory or not. Is there any command to do that?
Asked
Active
Viewed 1,443 times
2 Answers
4
https://code.kx.com/q/ref/dotq/#qpf-partition-type or one of the other .Q's should do it for you (https://code.kx.com/q/ref/card/#q). Though KX don't necessarily recommend using .Q utilities.
Another way would be to check for the existence of the variable "date" (if date-partitioned), which lists the available partitioned dates. Assuming there hasn't been a random unrelated global "date" variable created in the process.

Thomas Smyth - Treliant
- 4,993
- 6
- 25
- 36

terrylynch
- 11,844
- 13
- 21
-
1).Q.pf gives output `.Q.pf . I have also tried other Q utilities. 2)We can check for date variable but it is not generic as partition type can be different than date. – Rahul Sep 03 '14 at 06:10
-
1) if that is the case, you ran it on a non-partitioned database. Therefore a simpler answer would be to check `pf` is in the `Q` namespace. I think you meant '.Q.pf rather than \`.Q.pf – Manish Patel Sep 03 '14 at 06:22
-
@user2393012: So u mean that pf will only be there in Q namespace if it is a partition dir. If that is a case, then it might help. And yes, it is '.Q.pf (typo in my previous comment). – Rahul Sep 03 '14 at 07:31
-
2@Rahul: Yes that's right, it's a safe bet that it's partitioned db in that case. So you can do something like `\`pf in key\`.Q` - which just gives you a boolean – Manish Patel Sep 03 '14 at 08:54
0
You can check if par.txt
exists in db root (current working directory usually) - this may be a better alternative to relying on something internal within .Q
namespace, which is subject to change (although Kx rarely makes breaking changes to it).
So for a partitioned HDB, you'd get the following:
q) `par.txt in key`:.
1b

MdSalih
- 1,978
- 10
- 16
-
2par.txt is not a compulsory requirement for partitioned database. It is used for segmented database. So can't use this for checking partitioned HDB. – Rahul Sep 04 '14 at 13:55