Data-driven machinery fault diagnosis is important for smart industrial systems to guarantee safety and reliability. However, the conventional data-driven fault diagnosis methods rely on the expert-designed features, which greatly affect the diagnosis performances. Inspired by the sparse representation-based classification (SRC) methods which can learn discriminative sparse features adaptively, we propose a novel discriminative dictionary learning based sparse classification (DDL-SC) framework for data-driven machinery fault diagnosis. The DDL-SC framework can jointly learn a discriminative dictionary for sparse representation and an optimal linear classifier for pattern recognition, which bridges the gaps between two separate processes, dictionary learning and classifier training in traditional SRC methods. In the learning stage, to enhance the discriminability of dictionary learning, we introduce the discriminative sparse code error along with the reconstruction error and classification error into the optimization objective. In the recognition stage, we employ sparse codes of testing signals with respect to the learned discriminative dictionary as inputs of the learned classifier, and promote the recognition performance by connecting a binary hard thresholding operator with the classifier predictions. The effectiveness of DDL-SC is evaluated on the planetary bearing fault dataset and gearbox fault dataset, indicating that DDL-SC yields the recognition accuracies of 99.73% and 99.41%, respectively. Besides, the comparative studies prove the superiority of DDL-SC over several state-of-the-art methods for data-driven machinery fault diagnosis.